I was asked to encrypt a password by creating a new procedure and what I was thinking was to work with bits to change each character of my input key with apparently unrelated characters, and so I wrote this function:
(I'm working with PHP code):
function CBS($digits, $n_times) {
$mask = 0x7FFFFFFF;
$digits = intval($digits);
if($n_times > 0) {
$digits = ($digits<<$n_times%32) & (($digits>>(32-$n_times%32)) & ($mask>>(31-$n_times%32)));
}elseif($n_times < 0) {
$n_times = abs($n_times);
$digits = (($digits>>$n_times%32) & ($mask >> (-1+$n_times%32))) | ($digits<<(32-$n_times%32));
}
return decbin($digits);
}
Of course after I encrypted my password I should be able to decrypt it.
Is there any way to do that?
You don't need to write me the code to do it, it would be great if you could explain it to me with words, too.