/ Published in: Awk
URL: http://www.topcat.hypermart.net/index.html
xor encryption for gawk.
Expand |
Embed | Plain Text
# xorEncode - Topcat Software LLC. 2011 # http://www.topcat.hypermart.net/index.html # note: xor is specific to GNU (gawk) # more info about xor at: http://en.wikipedia.org/wiki/XOR_cipher # usage example: # foo = xorEncode("we can be heros...", "mypassword") # bar = xorEncode(foo, "mypassword") # print foo # prinr bar function xorEncode(str, pass, x, y, z, j, ord_a, str_a, pass_a, buf) { x = split(str, str_a, "") y = split(pass, pass_a, "") for (z = 1; z <= 255; z++) {ord_a[sprintf("%c", z)] = z} for (j = z = 1; z <= x; z++) { buf = buf sprintf("%c", xor(ord_a[str_a[z]], ord_a[pass_a[j]])) j = (j < y) ? j++ : 1 } return buf }
You need to login to post a comment.
