Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

how to handle spaces ? #284

Open
AdrienLemaire opened this issue Oct 1, 2022 · 2 comments
Open

how to handle spaces ? #284

AdrienLemaire opened this issue Oct 1, 2022 · 2 comments

Comments

@AdrienLemaire
Copy link

Generating keys as follow

var key = encrypt.Key.fromUtf8(aesKey);
var iv = encrypt.IV.fromLength(16);
final encrypter = encrypt.Encrypter(encrypt.AES(key, padding: null));
final code = encrypter
    .encrypt(myString, iv: iv)
    .base64;

I notice that regularly, a code will be generated with a space in it, eg MjvmDDtmCLTg AxL1GrBVK4Ns1vKtm/qtwARv5fyWBPHWg==
In that case, the following code breaks:

encrypt.Encrypted.fromBase64(code)

traceback

══╡ EXCEPTION CAUGHT BY WIDGETS LIBRARY ╞═══════════════════════════════════════════════════════════
The following FormatException was thrown building Builder(dirty):
Invalid character (at character 13)
MjvmDDtmCLTg AxL1GrBVK4Ns1vKtm/qtwARv5fyWBPHWg==
            ^

What is the proper resolution in this case ?

@AdrienLemaire
Copy link
Author

@leocavalcante hi Leo, this error occurs quite frequently for me, so I'm assuming this is not a library bug but something I did wrong ? Do you have any idea what could cause this "Invalid character" error and how I could resolve it ?

@AdrienLemaire
Copy link
Author

@leocavalcante is the project not maintained anymore ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant