Is it possible to decrypt a base 64 text with a key and AES standard?
I'm working with Python and the Pycryptodome library.
I have a string beginning with 951bd9...[and so on]
.
Let's suppose I have a key"ThisIsARandomText"
.
My question is : could I decrypt that string with an AES algorithm and that key ?
I think I don't get it all and I would be pleased to have some explanations to improve.
Thanks you very much for your help !
do you know?
how many words do you know
See also questions close to this topic
-
Python File Tagging System does not retrieve nested dictionaries in dictionary
I am building a file tagging system using Python. The idea is simple. Given a directory of files (and files within subdirectories), I want to filter them out using a filter input and tag those files with a word or a phrase.
If I got the following contents in my current directory:
data/ budget.xls world_building_budget.txt a.txt b.exe hello_world.dat world_builder.spec
and I execute the following command in the shell:
py -3 tag_tool.py -filter=world -tag="World-Building Tool"
My output will be:
These files were tagged with "World-Building Tool": data/ world_building_budget.txt hello_world.dat world_builder.spec
My current output isn't exactly like this but basically, I am converting all files and files within subdirectories into a single dictionary like this:
def fs_tree_to_dict(path_): file_token = '' for root, dirs, files in os.walk(path_): tree = {d: fs_tree_to_dict(os.path.join(root, d)) for d in dirs} tree.update({f: file_token for f in files}) return tree
Right now, my dictionary looks like this:
key:''
.In the following function, I am turning the empty values
''
into empty lists (to hold my tags):def empty_str_to_list(d): for k,v in d.items(): if v == '': d[k] = [] elif isinstance(v, dict): empty_str_to_list(v)
When I run my entire code, this is my output:
hello_world.dat ['World-Building Tool'] world_builder.spec ['World-Building Tool']
But it does not see
data/world_building_budget.txt
. This is the full dictionary:{'data': {'world_building_budget.txt': []}, 'a.txt': [], 'hello_world.dat': [], 'b.exe': [], 'world_builder.spec': []}
This is my full code:
import os, argparse def fs_tree_to_dict(path_): file_token = '' for root, dirs, files in os.walk(path_): tree = {d: fs_tree_to_dict(os.path.join(root, d)) for d in dirs} tree.update({f: file_token for f in files}) return tree def empty_str_to_list(d): for k, v in d.items(): if v == '': d[k] = [] elif isinstance(v, dict): empty_str_to_list(v) parser = argparse.ArgumentParser(description="Just an example", formatter_class=argparse.ArgumentDefaultsHelpFormatter) parser.add_argument("--filter", action="store", help="keyword to filter files") parser.add_argument("--tag", action="store", help="a tag phrase to attach to a file") parser.add_argument("--get_tagged", action="store", help="retrieve files matching an existing tag") args = parser.parse_args() filter = args.filter tag = args.tag get_tagged = args.get_tagged current_dir = os.getcwd() files_dict = fs_tree_to_dict(current_dir) empty_str_to_list(files_dict) for k, v in files_dict.items(): if filter in k: if v == []: v.append(tag) print(k, v) elif isinstance(v, dict): empty_str_to_list(v) if get_tagged in v: print(k, v)
-
Actaully i am working on a project and in it, it is showing no module name pip_internal plz help me for the same. I am using pycharm(conda interpreter
File "C:\Users\pjain\AppData\Local\Programs\Python\Python310\lib\runpy.py", line 196, in _run_module_as_main return _run_code(code, main_globals, None, File "C:\Users\pjain\AppData\Local\Programs\Python\Python310\lib\runpy.py", line 86, in _run_code exec(code, run_globals) File "C:\Users\pjain\AppData\Local\Programs\Python\Python310\Scripts\pip.exe\__main__.py", line 4, in <module> File "C:\Users\pjain\AppData\Local\Programs\Python\Python310\lib\site-packages\pip\_internal\__init__.py", line 4, in <module> from pip_internal.utils import _log
I am using pycharm with conda interpreter.
-
Looping the function if the input is not string
I'm new to python (first of all) I have a homework to do a function about checking if an item exists in a dictionary or not.
inventory = {"apple" : 50, "orange" : 50, "pineapple" : 70, "strawberry" : 30} def check_item(): x = input("Enter the fruit's name: ") if not x.isalpha(): print("Error! You need to type the name of the fruit") elif x in inventory: print("Fruit found:", x) print("Inventory available:", inventory[x],"KG") else: print("Fruit not found") check_item()
I want the function to loop again only if the input written is not string. I've tried to type return Under print("Error! You need to type the name of the fruit") but didn't work. Help
-
Please help to find email out of this cipher
Please help me to extract the email from this cipher, i am not been able to identify what type of hash or cipher is this.email is encoded in this hash please help me find the email.
1AAXs0RyFR3OM9nZA3XVkD07AVOZmYUMsRvyeq2BoY42sNbkSUySHCdFdwwQx6LWghNDqiPyBzNE7KDXkerX4vt0klZ2
-
Having error with .cer file for As2 communication for validation
Trying to setup the As2 communication for walmart vendor. Using the as2gateway site and have everything correct for communication on both sides. Receiving the email on site but getting error.
MDN report
Message Disposition Notification
Reporting-UA: AdroitLogic AS2-X/latest Original-Recipient: rfc822; Larry-Smith1 Final-Recipient: rfc822; Larry-Smith1 Original-Message-ID: <CLEO-20220507_032305226-77N95E@08925485US00_Larry-Smith1-K> Disposition: automatic-action/MDN-sent-automatically;failed/error: authentication-failed Received-Content-MIC: u722DTqJUUlmR35anz0AUcEfbhc=, sha1
MDN for Message-ID: <CLEO-20220507_032305226-77N95E@08925485US00_Larry-Smith1-K> From: 08925485US00 To: Larry-Smith1 Received on: Sat May 07 03:23:05 UTC 2022 Status: failed Comment: Message processing failed due to the following errors Errors encountered : error: Cannot validate message signers of : <CLEO-20220507_032305226-77N95E@08925485US00_Larry-Smith1-K> - Cause : Trust anchor for certification path not found. - Signers : CN=Larry-Smith1, OU=Prod, O=WM, L=Bentonville, C=US
Original Message Tracking Information (provided by Harmony):
Sent-Content-MIC: u722DTqJUUlmR35anz0AUcEfbhc=, sha1 Sent-Message-ID: CLEO-20220507_032305226-77N95E@08925485US00_Larry-Smith1-K Transfer-ID: AS2-20220506_222305222-K;40771661-61a7-494b-b8f6-301405e2c918 Original-Filename: sendTest_X12 Original-Subject: EDIINTDATA Original-Send-Date: Sat, 07 May 2022 03:23:05 GMT Signed-Request: true Encrypted-Request: true Compressed-Request: false Encryption-Algorithm: TripleDES Key-Algorithm: RSA Signature-Algorithm: RSA Hash-Algorithm: SHA-1 Response-Method: synchronous Sender: 08925485US00 Recipient: Larry-Smith1 Host: 48794_TestConn Mailbox: 48794_TestConn Restart-On-Failure: false Signed-MDN: true Signed-By: C=us,ST=X,L=X,OU=EDI Integration,O=Larry Smith Books,CN=X Serial-No: 1806D466C49 Signer-Signature-Algorithm: rsaEncryption Signer-Hash-Algorithm: SHA1
It is a private encryption. This could be why getting error but don't know how to resolve. Have been reading articles to try to find a solution or how to get certificate authority validation.
-
What is the strongest method, using netcore, to decrypt and encrypt passwords?
I am developing an encryption and decryption engine for passwords. I need to encrypt a password and store the result in a repository. The user needs to decrypt the result when needed.
So in Netcore and C# what is the strongest method to do this?
Thanks in advance
-
How do I monitor transactions in a Polygon wallet?
So I'm wanting to monitor a Polygon wallet for when transactions occur. It doesn't seem like there are a ton of resources for Polygon wallet monitoring, mostly just for Bitcoin and Ethereum wallet monitoring. What's the process to develop a program to monitor a Polygon wallet? Is there an API I can use?
-
How to implement a rehostable licenced software
I have already implemented a software licensing via a license file. I am planning to make this software rehostable. That is, a user can migrate his licensed software from one PC to another PC.
I wondering is there any cryptographic techniques that can prevent a user from using the licensed software on his old PC that once the software license has been migrated. Giving the fact that, a user can by pass this restriction by backing up his system before the rehosting process. (Uses may stay offline)
-
Find the subproblems for parallel RSA cracker
RSA algorithm: you need to take user input for two prime numbers, p and q and then generated a public key and encrypted msg and private key. Then use this private key to decrypt or find the plain text from the encrypted msg.
RSA cracker: you have user input for encrypted msg, public key and N(modulus) using those you need to generate the private key and plain text.
I am trying to build a RSA cracker which I can use for parallel programing(CUDA -C)
I have a function to generate private key and another function to generate plain text.
I am taking user input for encrypted message and public key and modulus N. So I need to find out two prime numbers(p, q) whose product should be N. N= p*q. I went though this tutorial.
My serial code runs fine. However, for parallel code I haven't understood which portion I need to paralyzed. To launch threads in CUDA kernel I need to have independent subproblems of main problem. But in RSA cracker which portion can be implemented as independent subproblem?
Thank you.
-
convert plain text To hexa value using AES Cryptojs in Vanilla js
I am trying to convert this encrypted value to Hex form. Is there any simple way to do it?. Also i want to make key as a string(email)
function encrypt() { var encrypted = CryptoJS.AES.encrypt( document.getElementById("text").value, document.getElementById("email").value ) document.getElementById("EncryptedValue").innerHTML = encrypted; document.getElementById("decrypted").innerHTML = ""; }
-
VB.net To Js AES Encryption
I want to be able to encrypt data in javascript and compare it in Vb.net, however the two scripts do not return the same value.
text input : azerty123 key pass : qwerty1234
VB.NET
'Encrypt a string with AES Public Function CryptAES(ByVal input As String, ByVal pass As String) As String Dim AES As New System.Security.Cryptography.RijndaelManaged Dim Hash_AES As New System.Security.Cryptography.MD5CryptoServiceProvider Dim encrypted As String = "" Try Dim hash(31) As Byte Dim temp As Byte() = Hash_AES.ComputeHash(System.Text.Encoding.UTF8.GetBytes(pass)) ' Dim temp As Byte() = Hash_AES.ComputeHash(System.Text.ASCIIEncoding.ASCII.GetBytes(pass)) Array.Copy(temp, 0, hash, 0, 16) Array.Copy(temp, 0, hash, 15, 16) AES.Padding = PaddingMode.PKCS7 AES.KeySize = 256 AES.Key = hash AES.Mode = CipherMode.ECB Dim DESEncrypter As System.Security.Cryptography.ICryptoTransform = AES.CreateEncryptor Dim Buffer As Byte() = System.Text.Encoding.UTF8.GetBytes(input) ' Dim Buffer As Byte() = System.Text.ASCIIEncoding.ASCII.GetBytes(input) encrypted = Convert.ToBase64String(DESEncrypter.TransformFinalBlock(Buffer, 0, Buffer.Length)) Return encrypted Catch ex As Exception Return input 'If encryption fails, return the unaltered input. End Try End Function 'Decrypt a string with AES Public Function DecryptAES(ByVal input As String, ByVal pass As String) As String Dim AES As New System.Security.Cryptography.RijndaelManaged Dim Hash_AES As New System.Security.Cryptography.MD5CryptoServiceProvider Dim decrypted As String = "" Try Dim hash(31) As Byte Dim temp As Byte() = Hash_AES.ComputeHash(System.Text.Encoding.Default.GetBytes(pass)) 'Dim temp As Byte() = Hash_AES.ComputeHash(System.Text.ASCIIEncoding.ASCII.GetBytes(pass)) Array.Copy(temp, 0, hash, 0, 16) Array.Copy(temp, 0, hash, 15, 16) AES.Padding = PaddingMode.PKCS7 AES.KeySize = 256 AES.Key = hash AES.Mode = CipherMode.ECB Dim DESDecrypter As System.Security.Cryptography.ICryptoTransform = AES.CreateDecryptor Dim Buffer As Byte() = Convert.FromBase64String(input) decrypted = System.Text.Encoding.Default.GetString(DESDecrypter.TransformFinalBlock(Buffer, 0, Buffer.Length)) 'decrypted = System.Text.ASCIIEncoding.ASCII.GetString(DESDecrypter.TransformFinalBlock(Buffer, 0, Buffer.Length)) Return decrypted Catch ex As Exception Return input 'If decryption fails, return the unaltered input. End Try End Function
return AnQHmip8sfrIqPHYun3vSQ==
JS use https://www.npmjs.com/package/crypto-js
router.post("/encrypt", (req, res, next) => { const key = CryptoJS.enc.Utf8.parse('qwerty1234'); let ciphertext = CryptoJS.AES.encrypt(req.body.value.toString(), key, {mode: CryptoJS.mode.ECB}).toString(); return res.status(200).json({encrypted: ciphertext}); })
return UtOXdzYOBC0wnG5pe6Ndkw==
-
Why does decrypting modified AES-CBC ciphertext fail decryption?
I am trying to get familiar with encryption/decryption. I am using deno as it supports the web crypto API.
I can encrypt and decrypt to get back the original plaintext using AES-CBC.
What I am now doing now is to encrypt, then manually modify the ciphertext and then decrypt. My expectation is that this would still work since I understand that AES-CBC does not provide integrity and authenticity check. (AES-GCM is the one that is AEAD)
But when I modify the cipher text and try to decrypt, it fails with the following error:
error: Uncaught (in promise) OperationError: Decryption failed let deCryptedPlaintext = await window.crypto.subtle.decrypt(param, key, asByteArray); ^ at async SubtleCrypto.decrypt (deno:ext/crypto/00_crypto.js:598:29) at async file:///Users/me/delete/run.js:33:26
Does AES-CBC also have integrity checks? Or why is the decryption failing?
-
Is it possible to reverse a HMAC hash with Python?
I discovered the Hash-based Message Authentication Code (HMAC) and how to use it with a SHA-256 hash for example.
I follow that link https://pycryptodome.readthedocs.io/en/latest/src/hash/hmac.html.So I gave it a try and understood how to generate a HMAC, see the snippet below :
mySecret = b"....." h = HMAC.new(mySecret, digestmod = SHA256) h.update(b"hello") print (h.hexdigest()) # 1bef439a8c4fe14770480ebe819cb2e7d5cd68ca4ccf4b3c1f248fc2a525b0a9
Everything is ok on this part.
Then I searched how I could do to reverse it and getmySecret
back. And I must admit I have no ideas to make it.
It it possible to do it ?Thanks.
-
how to encrypt a decrypted code using cryptography module
key = '24305c3a354951afe96d1800ad9299bf'
iv = 'heF9BATUfWuISyO8' data=b'connection_type=wifi&app_name=MLB9Innings17&app_version=21&app_version_name=2.0.2&country_code=in&device_brand=Videocon&device_carrier=Jio+4G&device_cpu_type=armv8l&device_model=V502430&google_aid=b2753f4e-8aad-44dd-b7b6-823923eb5d67&google_ad_tracking_disabled=0&insdate=1495711043&installer=com.android.vending&install_referrer=utm_source%3D%28not+set%29%26utm_medium%3D%28not+set%29&language=en&mat_id=cc92c5ce-b617-4b6a-b1ce-596da5077425&mobile_country_code=405&mobile_network_code=872&os_version=6.0&screen_density=2.0&screen_layout_size=1280x720&sdk_version=3.11.4&conversion_user_agent=Dalvik%2F2.1.0+%28Linux%3B+U%3B+Android+6.0%3B+V502430+Build%2FMRA58K%29¤cy_code=USD&revenue=0.0&system_date=1495711261 '
how can we encrypt data?