Coder Social home page Coder Social logo

Comments (14)

NTMS2017 avatar NTMS2017 commented on July 18, 2024

I need to send encrypted value to server using https. How do I do that with salsa?

from encrypt.

leocavalcante avatar leocavalcante commented on July 18, 2024

Sorry, I'm not a security expert to ensure you how secure your app will be, this lib is just a wrapper around PointyCastle.
Also, using https already makes the connection between your Flutter app and your server secure. You don't need an extra layer.

from encrypt.

NTMS2017 avatar NTMS2017 commented on July 18, 2024

Thanks for the info.

This is "1viEPvZsG2vlfwoBIZPEu5EOFJBlPsgUq+hkBuMFgJVYirS/X6KLPt3WCuuQ+qVMdU6fXb/z7w==" encrypted string. Now I need to send to server (aqueduct) using https. My problem how to decrypt the string to get original "Lorem ipsum dolor sit amet, consectetur adipiscing elit" string.

I couldn't find in source or documentation. So, is it possible to send me some info how to make it to work? Thanks

from encrypt.

NTMS2017 avatar NTMS2017 commented on July 18, 2024

In one of my old c# I use to make a block chipper on "des" to decode using chipper.decodeBase64. But I am not sure how to implement in here.

from encrypt.

leocavalcante avatar leocavalcante commented on July 18, 2024

You can:

final text = encrypter.decrypt64('1viEPvZsG2vlfwoBIZPEu5EOFJBlPsgUq+hkBuMFgJVYirS/X6KLPt3WCuuQ+qVMdU6fXb/z7w==');

Remember that you encrypter should be instantiated with proper key and IV.

https://github.com/leocavalcante/encrypt/blob/master/test/encrypt_test.dart#L48

from encrypt.

NTMS2017 avatar NTMS2017 commented on July 18, 2024

Thank you very much Leo.

Bear with me. What do you mean by saying " proper key and IV."? In your example you use Key.fromLength(32) and IV.fromLength(8).

Can you give me an example. Thanks

from encrypt.

leocavalcante avatar leocavalcante commented on July 18, 2024

Key.fromLength(32) and IV.fromLength(8) are just for examples and testing purposes. For production environments you should use cryptography strong values generated by a CSPRNG. And they should be the same on the side of the encryption and on the side of the decryption.

I'll reopen your issue as a remainder for me to work on something cool for that, PointyCastle does implemente Fortuna algorithm, we can have a CLI to generate keys/ivs :)

from encrypt.

NTMS2017 avatar NTMS2017 commented on July 18, 2024

Got it. Thanks again, :) I will looking forward.

from encrypt.

NTMS2017 avatar NTMS2017 commented on July 18, 2024

when I use string for key.fromUtf8("......") and iv it looks okay on dart console app. Then when I implement to my Flutter app and aqueduct on server I got error as shown below. End of the encrypted string has a = sign and find error on that part as invalid encoding.

Kks9SRyL5qRy/J6sgk3GglHVKbaqiI= 18ms 500 {user-agent : Dart/2.1 (dart:io)\nconnection : close\naccept : application/json\naccept-encoding : gzip\ncontent-length : 0\nhost : 127.0.0.1:3000\n} FormatException: Invalid encoding before padding (at character 31)
Kks9SRyL5qRy/J6sgk3GglHVKbaqiI=
^
#0 _Base64Decoder.decodeChunk (dart:convert/base64.dart:718:13)
#1 _Base64Decoder.decode (dart:convert/base64.dart:654:14)
#2 Base64Decoder.convert (dart:convert/base64.dart:516:32)
#3 Base64Codec.decode (dart:convert/base64.dart:91:47)

from encrypt.

leocavalcante avatar leocavalcante commented on July 18, 2024

Can you share your code? It seams that de decrypt function is receiving more than just the token...

from encrypt.

NTMS2017 avatar NTMS2017 commented on July 18, 2024

Sorry for late response, it was my side of the bad effect. iv is 10 bit. Adjust 8 bit and working very fast both in flutter app, dart server ans aqueduct. :)

from encrypt.

leocavalcante avatar leocavalcante commented on July 18, 2024

Ok, great 😃

from encrypt.

leocavalcante avatar leocavalcante commented on July 18, 2024

There we go!
You can create crypto secure random numbers for keys and ivs in your project!

Like:

Leo~ secure-random
Gg8bARwOEBYBEwAWERAfESEgHAsgByERGA0XGBwYCyE=
Leo~ secure-random -l 8
GgsgFxIJFwk=
Leo~ secure-random -l 16 -b 16
150b1d00161d111905211d0a0c1b2114

-l is for length and -b is for base (64 and 16 only):

https://github.com/leocavalcante/encrypt#secure-random

from encrypt.

NTMS2017 avatar NTMS2017 commented on July 18, 2024

I didnt know how to create crypto secure random numbers for keys and ivs. Thanks again Leo.

from encrypt.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.