sophuwu.site > seks
made decoder
sophuwu sophie@sophuwu.site
Sun, 15 Oct 2023 10:46:50 +0200
commit

82d3b45cfada12e84b238be74cd1afdbacaed29a

parent

4946ed9cd1ac0fd8b2d98da6c20b3b7247dd757c

1 files changed, 23 insertions(+), 7 deletions(-)

jump to
M main.gomain.go

@@ -13,8 +13,6 @@ )

const hexKey string = "SOPHIE+MAL1VN=<3" -type hexEncoder []byte - func hexString(b []byte) string { var s string for i := 0; i < len(b); i++ {

@@ -24,6 +22,14 @@ }

return s } +func hexUnString(s string) []byte { + var b []byte + for i := 0; i < len(s); i += 2 { + b = append(b, byte(hexKey[s[i]]<<4)|byte(hexKey[s[i+1]])) + } + return b +} + func ran() []byte { var b [32]byte _, err := rand.Reader.Read(b[:])

@@ -41,7 +47,8 @@ // User makes a password for each bucket

passwd := []byte("TestPassword") - salt := ran() + //salt := ran() + salt := hexUnString("3MN+1SML3OV<IVO1OMNENNL<MIOSMPP1ONOSL+=+NMPPVEOA++A<LPH1S3L+IIHA") hash := sha256.New() hash.Write(passwd) hash.Write(salt)

@@ -49,11 +56,20 @@

var key [32]byte copy(key[:], hash.Sum(nil)) - var nonce = [24]byte(ran()[0:24]) + //var nonce = [24]byte(ran()[0:24]) - message := []byte("I like to eat apples and bananas. However, I do not like to eat oranges. Cars can drive!") - encrypted := secretbox.Seal(nonce[:], message, &nonce, &key) + //message := []byte("I like to eat apples and bananas. However, I do not like to eat oranges. Cars can drive!") + //encrypted := secretbox.Seal(nonce[:], message, &nonce, &key) - fmt.Println(hexString(encrypted)) + //fmt.Println(hexString(encrypted)) + //fmt.Println(hexString(salt)) + encrypted := hexUnString("AHNS=+H+IMNH+OHOAHI+A==3SVVLMVII<O+NH3MSE3=SO+<SNMI1EP1+LONHHE3==N1OESVPSMNHN1=1PNHHSVAPHE+HV31O+OVE3N3IM+OAAA+1=LSO<N+<+IA<S1P+HLM<+=S<EEA<31=O1OSOM1IN3HEV<AILHAS<+S+ONVVLM3=V=+OPLLNSLH<S+=LPSVMM<SPIMNE<EV<MIPOOH+NHO<3A3=IS+ESS3E+SMPEL313MOVL1<N1INSAAE1HS") + var deNonce [24]byte = [24]byte(encrypted[0:24]) + decrypted, boolEnlon := secretbox.Open(nil, encrypted[24:], &deNonce, &key) + if boolEnlon != true { + fmt.Println("OOPS") + return + } + fmt.Println(string(decrypted)) }