Skip to content

Should identify that the key can only use AVAILABLE_CHARS characters #5

@ziserendexin

Description

@ziserendexin

I want use it to encrypt some low confidentiality string,and use the key like zise_some_thing_happen.
But the encryt_string is a bit long

It decrypt some charact worry(part of my data).
like:
"time": "2018-12-14 17:59:16",
to
"tyme": "2018-12-14 17:59:16",

And it will not show in short string.
the reason maybe is in this if.

if(isalnum(msg[i]) or msg[i] == ' ') {
    encryptedMsg[i] = AVAILABLE_CHARS[((index(msg[i]) + index(newKey[i])) % AVAILABLE_CHARS.size())];
} else {
    encryptedMsg[i] = msg[i];
}

After base64, some string will change to '_', and it will get worry index in newKey.

But I can't recurrent it in short string, and my error string have a little confidentiality needs. if you need it. Please give me a email, and i will send it to you.

On the other hand,
in

encryptedMsg[i] = AVAILABLE_CHARS[((index(msg[i]) + index(newKey[i])) % AVAILABLE_CHARS.size())];

AVAILABLE_CHARS.size() is a determine value, and .size() will caculate this value every time in your for loop.

It will better in this way:

AVAILABLE_CHARS_SIZE = AVAILABLE_CHARS.size()
for(i = 0; i < msgLen; ++i) {
    encryptedMsg[i] = AVAILABLE_CHARS[((index(msg[i]) + index(newKey[i])) % AVAILABLE_CHARS_SIZE)];
}

At last, in windows, call exe in cmd have max limit,32768. so if your encrypted string is too long, you can`t decrypt or encrypt it in python.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions