473,657 Members | 2,661 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

NCrypto Encryption & Decryption

Hi All.
I'm using the NCrypto dll for RSA Encryption/Decryption
(http://sourceforge.net/projects/ncrypto/). My encryption code in .Net
is pretty simple. The dataToEncrypt length is 1024. The returned data
is 1161 in length.

public static byte[] EncryptRSA(stri ng certFilePublic, byte[]
dataToEncrypt)
{
RSAParameters rsaParams = GetRSAPubKey(ce rtFilePublic);

byte[] decryptedData = null;
try
{
decryptedData =
NCrypto.Securit y.Cryptography. CryptoHelper.En crypt(dataToEnc rypt,
rsaParams, false);
return decryptedData;
}
catch (Exception eer)
{
System.Windows. Forms.MessageBo x.Show(eer.ToSt ring());
return null;
}
}
The problem is when I try to decrypt I get a "System.Argumen tOutOfRange
Exception: Data length must be a multiple of 128. Parameter name:
cipherText".
The problem is that the encrypt function creates data that is 1161
bytes long which isn't a multiple of 128.

I've tried changing the data size going into the decrypt function but
the data returned is always a multiple of 129 and not 128.

Please HELP! I'm so stuck as to what to do. :-(

Nov 17 '05 #1
0 1132

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
2419
by: D. Alvarado | last post by:
On my Fedora Core 2 Linux dev box, I have installed mcrypt and compiled PHP with the --with-mcrypt option. I am concerned that when I move to another hosting enviornment mcrypt will not be supported. In people's experiences, have hosting companies supporting PHP/MySQL generally provided support for mcrypt? Does anyone recommend another module for encryption/decryption that accompanies the PHP package? Thanks, - Dave
2
4192
by: Dave Bailey | last post by:
I have developed a web app using DPAPI to encrypt a connection string in the web.config file. The application works perfectly on the development machine but when deployed to the server when opening the app the following wrror is generated: Exception decrypting. Decryption failed. Key not valid for use in specified state. Description: An unhandled exception occurred during the execution of the current web request. Please review the
2
2577
by: sushant.bhatia | last post by:
Hi All. I'm using the NCrypto dll for RSA Encryption/Decryption (http://sourceforge.net/projects/ncrypto/). My encryption code in .Net is pretty simple. The dataToEncrypt length is 1024. The returned data is 1161 in length. public static byte EncryptRSA(string certFilePublic, byte dataToEncrypt) { RSAParameters rsaParams = GetRSAPubKey(certFilePublic);
2
7142
by: almurph | last post by:
Hi everyone, Can you help me please? I am having a problem with the encryption/decryption of words with the Irish fada in them. The Irish fada is like this: áéíóú/ÁÉÍÓÚ. It's kind of like the French grave... Anyway when I run encryption on a plaintext word like:
2
7684
by: Bernard Dhooghe | last post by:
The information center writes: "Encryption Algorithm: The internal encryption algorithm used is RC2 block cipher with padding, the 128-bit secret key is derived from the password using a MD2 message digest. " and also explains how the length of the encrypted column can be derived.
3
3058
by: =?Utf-8?B?TG9yZW4=?= | last post by:
I’m trying to encrypt and decrypt a file in vb.net. I am using the TripleDESCryptoServiceProvider encryption found in System.Security.Cryptography. Below is the code for my Encrypt and Decrypt functions. While my functions read and write files the encryption/decryption is not working properly. My test file has an original length of 66,048 bytes. My encrypted file ends up with 66,056 bytes … 8 bytes more than my original. When I...
13
3580
by: Tom Andrecht | last post by:
I'm trying to get some encryption/decryption routines going to take care of my data, and while the encryption is working great, I keep running into the message "Padding is invalid and cannot be removed" on the decryption piece. From everything I can see, I am doing things correctly here My code is as follows: private const string PassStr = "MyPrivateKey"; private static readonly byte PassSalt = new byte { Byte Byte Byte Byte Byte};...
5
9507
by: Netwatcher | last post by:
well, i started messing around with dictionaries, yet, most of the pages i found about them always talk about getting only one word out of it and turning it vice versa, i've been playing with that code for a few hours: #dics Encryption={',':'hy{;',' ':'h4x0r2','':'zomg','?':'bko','a':'ika','b':'d0v','c':'ino', 'd':'maw', 'e':'aon', 'f':'que', 'g':'kip', 'h':'an', 'n':'ko print lol except KeyError: print 'These...
9
4812
by: Betikci Boris | last post by:
I get bored last night and wrote a script that uses xor for encrypt- decrypt, however it woks fine under linux 2.6.25, text and documents are ok, but fails on compressed files *.jpg, *.pdf , etc . I didn't test script on windows. Here is the code, please send me your views. <?php /* Mother Eye Chipper with PHP :), Licence:GPL,
0
8407
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8837
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8739
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8512
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8612
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7347
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
4171
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4329
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
1732
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.