How to use hash class

Best Atoum code snippet using hash

ArrayLoader.php

Source:ArrayLoader.php Github

copy

Full Screen

...43 public function load($resource)44 {45 $features = array();46 if (isset($resource['features'])) {47 foreach ($resource['features'] as $iterator => $hash) {48 $feature = $this->loadFeatureHash($hash, $iterator);49 $features[] = $feature;50 }51 } elseif (isset($resource['feature'])) {52 $feature = $this->loadFeatureHash($resource['feature']);53 $features[] = $feature;54 }55 return $features;56 }57 /**58 * Loads feature from provided feature hash.59 *60 * @param array $hash Feature hash61 * @param integer $line62 *63 * @return FeatureNode64 */65 protected function loadFeatureHash(array $hash, $line = 0)66 {67 $hash = array_merge(68 array(69 'title' => null,70 'description' => null,71 'tags' => array(),72 'keyword' => 'Feature',73 'language' => 'en',74 'line' => $line,75 'scenarios' => array(),76 ),77 $hash78 );79 $background = isset($hash['background']) ? $this->loadBackgroundHash($hash['background']) : null;80 $scenarios = array();81 foreach ((array) $hash['scenarios'] as $scenarioIterator => $scenarioHash) {82 if (isset($scenarioHash['type']) && 'outline' === $scenarioHash['type']) {83 $scenarios[] = $this->loadOutlineHash($scenarioHash, $scenarioIterator);84 } else {85 $scenarios[] = $this->loadScenarioHash($scenarioHash, $scenarioIterator);86 }87 }88 return new FeatureNode($hash['title'], $hash['description'], $hash['tags'], $background, $scenarios, $hash['keyword'], $hash['language'], null, $hash['line']);89 }90 /**91 * Loads background from provided hash.92 *93 * @param array $hash Background hash94 *95 * @return BackgroundNode96 */97 protected function loadBackgroundHash(array $hash)98 {99 $hash = array_merge(100 array(101 'title' => null,102 'keyword' => 'Background',103 'line' => 0,104 'steps' => array(),105 ),106 $hash107 );108 $steps = $this->loadStepsHash($hash['steps']);109 return new BackgroundNode($hash['title'], $steps, $hash['keyword'], $hash['line']);110 }111 /**112 * Loads scenario from provided scenario hash.113 *114 * @param array $hash Scenario hash115 * @param integer $line Scenario definition line116 *117 * @return ScenarioNode118 */119 protected function loadScenarioHash(array $hash, $line = 0)120 {121 $hash = array_merge(122 array(123 'title' => null,124 'tags' => array(),125 'keyword' => 'Scenario',126 'line' => $line,127 'steps' => array(),128 ),129 $hash130 );131 $steps = $this->loadStepsHash($hash['steps']);132 return new ScenarioNode($hash['title'], $hash['tags'], $steps, $hash['keyword'], $hash['line']);133 }134 /**135 * Loads outline from provided outline hash.136 *137 * @param array $hash Outline hash138 * @param integer $line Outline definition line139 *140 * @return OutlineNode141 */142 protected function loadOutlineHash(array $hash, $line = 0)143 {144 $hash = array_merge(145 array(146 'title' => null,147 'tags' => array(),148 'keyword' => 'Scenario Outline',149 'line' => $line,150 'steps' => array(),151 'examples' => array(),152 ),153 $hash154 );155 $steps = $this->loadStepsHash($hash['steps']);156 if (isset($hash['examples']['keyword'])) {157 $examplesKeyword = $hash['examples']['keyword'];158 unset($hash['examples']['keyword']);159 } else {160 $examplesKeyword = 'Examples';161 }162 $examples = new ExampleTableNode($hash['examples'], $examplesKeyword);163 return new OutlineNode($hash['title'], $hash['tags'], $steps, $examples, $hash['keyword'], $hash['line']);164 }165 /**166 * Loads steps from provided hash.167 *168 * @param array $hash169 *170 * @return StepNode[]171 */172 private function loadStepsHash(array $hash)173 {174 $steps = array();175 foreach ($hash as $stepIterator => $stepHash) {176 $steps[] = $this->loadStepHash($stepHash, $stepIterator);177 }178 return $steps;179 }180 /**181 * Loads step from provided hash.182 *183 * @param array $hash Step hash184 * @param integer $line Step definition line185 *186 * @return StepNode187 */188 protected function loadStepHash(array $hash, $line = 0)189 {190 $hash = array_merge(191 array(192 'keyword_type' => 'Given',193 'type' => 'Given',194 'text' => null,195 'keyword' => 'Scenario',196 'line' => $line,197 'arguments' => array(),198 ),199 $hash200 );201 $arguments = array();202 foreach ($hash['arguments'] as $argumentHash) {203 if ('table' === $argumentHash['type']) {204 $arguments[] = $this->loadTableHash($argumentHash['rows']);205 } elseif ('pystring' === $argumentHash['type']) {206 $arguments[] = $this->loadPyStringHash($argumentHash, $hash['line'] + 1);207 }208 }209 return new StepNode($hash['type'], $hash['text'], $arguments, $hash['line'], $hash['keyword_type']);210 }211 /**212 * Loads table from provided hash.213 *214 * @param array $hash Table hash215 *216 * @return TableNode217 */218 protected function loadTableHash(array $hash)219 {220 return new TableNode($hash);221 }222 /**223 * Loads PyString from provided hash.224 *225 * @param array $hash PyString hash226 * @param integer $line227 *228 * @return PyStringNode229 */230 protected function loadPyStringHash(array $hash, $line = 0)231 {232 $line = isset($hash['line']) ? $hash['line'] : $line;233 $strings = array();234 foreach (explode("\n", $hash['text']) as $string) {235 $strings[] = $string;236 }237 return new PyStringNode($strings, $line);238 }239}...

Full Screen

Full Screen

hash.go

Source:hash.go Github

copy

Full Screen

...5import (6 "bytes"7 "crypto/sha256"8 "fmt"9 "hash"10 "io"11 "os"12 "runtime"13 "strings"14 "sync"15)16var debugHash = false // set when GODEBUG=gocachehash=117// HashSize is the number of bytes in a hash.18const HashSize = 3219// A Hash provides access to the canonical hash function used to index the cache.20// The current implementation uses salted SHA256, but clients must not assume this.21type Hash struct {22 h hash.Hash23 name string // for debugging24 buf *bytes.Buffer // for verify25}26// hashSalt is a salt string added to the beginning of every hash27// created by NewHash. Using the Go version makes sure that different28// versions of the go command (or even different Git commits during29// work on the development branch) do not address the same cache30// entries, so that a bug in one version does not affect the execution31// of other versions. This salt will result in additional ActionID files32// in the cache, but not additional copies of the large output files,33// which are still addressed by unsalted SHA256.34//35// We strip any GOEXPERIMENTs the go tool was built with from this36// version string on the assumption that they shouldn't affect go tool37// execution. This allows bootstrapping to converge faster: dist builds38// go_bootstrap without any experiments, so by stripping experiments39// go_bootstrap and the final go binary will use the same salt.40var hashSalt = []byte(stripExperiment(runtime.Version()))41// stripExperiment strips any GOEXPERIMENT configuration from the Go42// version string.43func stripExperiment(version string) string {44 if i := strings.Index(version, " X:"); i >= 0 {45 return version[:i]46 }47 return version48}49// Subkey returns an action ID corresponding to mixing a parent50// action ID with a string description of the subkey.51func Subkey(parent ActionID, desc string) ActionID {52 h := sha256.New()53 h.Write([]byte("subkey:"))54 h.Write(parent[:])55 h.Write([]byte(desc))56 var out ActionID57 h.Sum(out[:0])58 if debugHash {59 fmt.Fprintf(os.Stderr, "HASH subkey %x %q = %x\n", parent, desc, out)60 }61 if verify {62 hashDebug.Lock()63 hashDebug.m[out] = fmt.Sprintf("subkey %x %q", parent, desc)64 hashDebug.Unlock()65 }66 return out67}68// NewHash returns a new Hash.69// The caller is expected to Write data to it and then call Sum.70func NewHash(name string) *Hash {71 h := &Hash{h: sha256.New(), name: name}72 if debugHash {73 fmt.Fprintf(os.Stderr, "HASH[%s]\n", h.name)74 }75 h.Write(hashSalt)76 if verify {77 h.buf = new(bytes.Buffer)78 }79 return h80}81// Write writes data to the running hash.82func (h *Hash) Write(b []byte) (int, error) {83 if debugHash {84 fmt.Fprintf(os.Stderr, "HASH[%s]: %q\n", h.name, b)85 }86 if h.buf != nil {87 h.buf.Write(b)88 }89 return h.h.Write(b)90}91// Sum returns the hash of the data written previously.92func (h *Hash) Sum() [HashSize]byte {93 var out [HashSize]byte94 h.h.Sum(out[:0])95 if debugHash {96 fmt.Fprintf(os.Stderr, "HASH[%s]: %x\n", h.name, out)97 }98 if h.buf != nil {99 hashDebug.Lock()100 if hashDebug.m == nil {101 hashDebug.m = make(map[[HashSize]byte]string)102 }103 hashDebug.m[out] = h.buf.String()104 hashDebug.Unlock()105 }106 return out107}108// In GODEBUG=gocacheverify=1 mode,109// hashDebug holds the input to every computed hash ID,110// so that we can work backward from the ID involved in a111// cache entry mismatch to a description of what should be there.112var hashDebug struct {113 sync.Mutex114 m map[[HashSize]byte]string115}116// reverseHash returns the input used to compute the hash id.117func reverseHash(id [HashSize]byte) string {118 hashDebug.Lock()119 s := hashDebug.m[id]120 hashDebug.Unlock()121 return s122}123var hashFileCache struct {124 sync.Mutex125 m map[string][HashSize]byte126}127// FileHash returns the hash of the named file.128// It caches repeated lookups for a given file,129// and the cache entry for a file can be initialized130// using SetFileHash.131// The hash used by FileHash is not the same as132// the hash used by NewHash.133func FileHash(file string) ([HashSize]byte, error) {134 hashFileCache.Lock()135 out, ok := hashFileCache.m[file]136 hashFileCache.Unlock()137 if ok {138 return out, nil139 }140 h := sha256.New()141 f, err := os.Open(file)142 if err != nil {143 if debugHash {144 fmt.Fprintf(os.Stderr, "HASH %s: %v\n", file, err)145 }146 return [HashSize]byte{}, err147 }148 _, err = io.Copy(h, f)149 f.Close()150 if err != nil {151 if debugHash {152 fmt.Fprintf(os.Stderr, "HASH %s: %v\n", file, err)153 }154 return [HashSize]byte{}, err155 }156 h.Sum(out[:0])157 if debugHash {158 fmt.Fprintf(os.Stderr, "HASH %s: %x\n", file, out)159 }160 SetFileHash(file, out)161 return out, nil162}163// SetFileHash sets the hash returned by FileHash for file.164func SetFileHash(file string, sum [HashSize]byte) {165 hashFileCache.Lock()166 if hashFileCache.m == nil {167 hashFileCache.m = make(map[string][HashSize]byte)168 }169 hashFileCache.m[file] = sum170 hashFileCache.Unlock()171}...

Full Screen

Full Screen

hash

Using AI Code Generation

copy

Full Screen

1$hash = new hash();2$hash->md5('password');3$hash = new hash();4$hash->md5('password');5$hash = new hash();6$hash->md5('password');7$hash = new hash();8$hash->md5('password');9$hash = new hash();10$hash->md5('password');11$hash = new hash();12$hash->md5('password');13$hash = new hash();14$hash->md5('password');15$hash = new hash();16$hash->md5('password');17$hash = new hash();18$hash->md5('password');19$hash = new hash();20$hash->md5('password');21$hash = new hash();22$hash->md5('password');23$hash = new hash();24$hash->md5('password');25$hash = new hash();26$hash->md5('password');27$hash = new hash();28$hash->md5('password');29$hash = new hash();30$hash->md5('password');31$hash = new hash();32$hash->md5('password');

Full Screen

Full Screen

hash

Using AI Code Generation

copy

Full Screen

1$hash = new hash();2$hash->setAlgo('sha1');3$hash->setString('toto');4echo $hash->hash();5$hash = new hash();6$hash->setAlgo('sha1');7$hash->setString('toto');8echo $hash->hash();

Full Screen

Full Screen

hash

Using AI Code Generation

copy

Full Screen

1require_once '/path/to/Atoum/Hash.php';2$hash = new Atoum\Hash;3require_once '/path/to/Atoum/Hash.php';4$hash = new Atoum\Hash;5require_once '/path/to/Atoum/Hash.php';6$hash = new Atoum\Hash;7require_once '/path/to/Atoum/Hash.php';8$hash = new Atoum\Hash;9require_once '/path/to/Atoum/Hash.php';10$hash = new Atoum\Hash;11require_once '/path/to/Atoum/Hash.php';12$hash = new Atoum\Hash;13require_once '/path/to/Atoum/Hash.php';14$hash = new Atoum\Hash;15require_once '/path/to/Atoum/Hash.php';16$hash = new Atoum\Hash;17require_once '/path/to/Atoum/Hash.php';18$hash = new Atoum\Hash;

Full Screen

Full Screen

hash

Using AI Code Generation

copy

Full Screen

1use \mageekguy\atoum\hash as hash;2use \mageekguy\atoum;3$script->addTestDirectory('tests/units/');4$runner->addExtension(new hash\extension($script));5$runner->addTestsFromDirectory('tests/units/');6$runner->disableCodeCoverage();7$runner->enableCodeCoverage();8$runner->setBootstrapFile('tests/bootstrap.php');9$runner->addDefaultReport();10$runner->setPhpPath('/usr/bin/php');11$runner->setPhpPath('C:\PHP\php.exe');12$runner->addReport($report = new atoum\reports\realtime\cli());13$report->addField(new atoum\report\fields\runner\result\logo());14$report->addField(new atoum\report\fields\runner\result\duration());15$report->addField(new atoum\report\fields\runner\result\memory());16$report->addField(new atoum\report\fields\runner\result\readme());17$report->addField(new atoum\report\fields\runner\failures\logo());18$report->addField(new atoum\report\fields\runner\failures\failures());19$report->addField(new atoum\report\fields\runner\failures\errors());20$report->addField(new atoum\report\fields\runner\failures\exceptions());21$report->addField(new atoum\report\fields\runner\failures\outputs());22$report->addField(new atoum\report\fields\runner\outputs\logo());23$report->addField(new atoum\report\fields\runner\outputs\outputs());24$report->addField(new atoum\report\fields\runner\coverage\logo());25$report->addField(new atoum\report\fields\runner\coverage\clover('path/to/clover.xml'));26$report->addField(new atoum\report\fields\runner\coverage\php('path/to/coverage.php'));27$report->addField(new atoum\report\fields\runner\coverage\text());28$report->addField(new atoum\report\fields\

Full Screen

Full Screen

hash

Using AI Code Generation

copy

Full Screen

1$hash = new \hash();2$hash->addFile('test.txt');3$hash = new \hash();4$hash->addFile('test.txt');5$hash = new \hash();6$hash->addFile('test.txt');7$hash = new \hash();8$hash->addFile('test.txt');9$hash = new \hash();10$hash->addFile('test.txt');11$hash = new \hash();12$hash->addFile('test.txt');13$hash = new \hash();14$hash->addFile('test.txt');15$hash = new \hash();16$hash->addFile('test.txt');17$hash = new \hash();18$hash->addFile('test.txt');19$hash = new \hash();20$hash->addFile('test.txt');21$hash = new \hash();22$hash->addFile('test.txt');23$hash = new \hash();24$hash->addFile('test.txt');25$hash = new \hash();26$hash->addFile('test.txt');27$hash = new \hash();28$hash->addFile('test.txt');29$hash = new \hash();30$hash->addFile('test.txt');31$hash = new \hash();32$hash->addFile('test.txt');33$hash = new \hash();34$hash->addFile('test.txt');

Full Screen

Full Screen

hash

Using AI Code Generation

copy

Full Screen

1$hash = new hash();2$hash->test();3$hash = new hash();4$hash->test();5$hash = new hash();6$hash->test();7$hash = new hash();8$hash->test();9$hash = new hash();10$hash->test();11$hash = new hash();12$hash->test();13$hash = new hash();14$hash->test();15$hash = new hash();16$hash->test();17$hash = new hash();

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Atoum automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Run Selenium Automation Tests on LambdaTest Cloud Grid

Trigger Selenium automation tests on a cloud-based Grid of 3000+ real browsers and operating systems.

Test now for Free

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful