|
// retoor <retoor@molodetz.nl>
|
|
|
|
import "crypto" for Crypto, Hash
|
|
|
|
var bytes = Crypto.randomBytes(16)
|
|
System.print(bytes is List) // expect: true
|
|
System.print(bytes.count) // expect: 16
|
|
|
|
var md5 = Hash.md5("hello")
|
|
System.print(Hash.toHex(md5)) // expect: 5d41402abc4b2a76b9719d911017c592
|
|
|
|
var sha1 = Hash.sha1("hello")
|
|
System.print(Hash.toHex(sha1)) // expect: aaf4c61ddcc5e8a2dabede0f3b482cd9aea9434d
|
|
|
|
var sha256 = Hash.sha256("hello")
|
|
System.print(Hash.toHex(sha256)) // expect: 2cf24dba5fb0a30e26e83b2ac5b9e29e1b161e5c1fa7425e73043362938b9824
|
|
|
|
var emptyMd5 = Hash.md5("")
|
|
System.print(Hash.toHex(emptyMd5)) // expect: d41d8cd98f00b204e9800998ecf8427e
|