Data update
This commit is contained in:
parent
5150844a7d
commit
4bb20c9b71
7735 changed files with 38060 additions and 199180 deletions
|
|
@ -1,33 +1,33 @@
|
|||
beads 1 program 'Caesar cipher'
|
||||
calc main_init
|
||||
var str = "The five boxing wizards (🤖) jump quickly."
|
||||
log "Plain: {str}"
|
||||
str = Encrypt(str, 3)
|
||||
log "Encrypted: {str}"
|
||||
str = Decrypt(str, 3)
|
||||
log "Decrypted: {str}"
|
||||
var str = "The five boxing wizards (🤖) jump quickly."
|
||||
log "Plain: {str}"
|
||||
str = Encrypt(str, 3)
|
||||
log "Encrypted: {str}"
|
||||
str = Decrypt(str, 3)
|
||||
log "Decrypted: {str}"
|
||||
|
||||
// encrypt a string by shifting the letters over by a number of slots
|
||||
// pass through any characters that are not in the Roman alphabet
|
||||
calc Encrypt(
|
||||
input:str --- string to encrypt
|
||||
nshift --- number of characters to slide over
|
||||
) : str --- encrypted string
|
||||
|
||||
var newStr = ""
|
||||
loop from:1 to:str_len(input) count:myCount
|
||||
var unicode : num = from_char(subset(input, from:myCount, len:1))
|
||||
if unicode >= 65 and unicode <= 90
|
||||
unicode = mod((unicode - 65 + nshift), 26) + 65
|
||||
elif unicode >= 97 and unicode <= 122
|
||||
unicode = mod((unicode - 97 + nshift), 26) + 97
|
||||
newStr = newStr & to_char(unicode)
|
||||
return newStr
|
||||
input:str --- string to encrypt
|
||||
nshift --- number of characters to slide over
|
||||
) : str --- encrypted string
|
||||
|
||||
var newStr = ""
|
||||
loop from:1 to:str_len(input) count:myCount
|
||||
var unicode : num = from_char(subset(input, from:myCount, len:1))
|
||||
if unicode >= 65 and unicode <= 90
|
||||
unicode = mod((unicode - 65 + nshift), 26) + 65
|
||||
elif unicode >= 97 and unicode <= 122
|
||||
unicode = mod((unicode - 97 + nshift), 26) + 97
|
||||
newStr = newStr & to_char(unicode)
|
||||
return newStr
|
||||
|
||||
// undo the encryption
|
||||
calc Decrypt(
|
||||
input:str
|
||||
nshift
|
||||
) : str
|
||||
// we could also just shift by 26-nshift, same as going in reverse
|
||||
return Encrypt(input, -nshift)
|
||||
input:str
|
||||
nshift
|
||||
) : str
|
||||
// we could also just shift by 26-nshift, same as going in reverse
|
||||
return Encrypt(input, -nshift)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue