SASL password normalization - passwords

there is very simple question - can you normalize for me some password, because I can't understand how it works? So, there is password: "IDoMdGuFE9S0", how it looks in "normalized" view? There are only alphanumeric ascii characters. Does result and original be equal?
PS: Sorry for my bad English.

I'm assuming with "normalized" you mean SASLpreped. In the case of "IDoMdGuFE9S0", the output is the same as the input (it is fully ASCII, with no control sequences or U+00AD).
If you're writing an application that uses SASL, you should find a library to do this for you.

Related

System.Web.HttpUtility.UrlEncode method gives wrong result with different language value

Web.HttpUtility.UrlEncode method in my project. When I am encoding name in English language then I got correct result. For example,
string temp = System.Web.HttpUtility.UrlEncode("Jewelry");
then I got exact result in temp variable. But if I wrote name in Russian language then I got different result.
string temp = System.Web.HttpUtility.UrlEncode("ювелирные изделия");
then I got value in temp variable like "%d1%8e%d0%b2%d0%b5%d0%bb%d0%b8%d1%80%d0%bd%d1%8b%d0%b5+%d0%b8%d0%b7%d0%b4%d0%b5%d0%bb%d0%b8%d1%8f"
Can anyone help me how to achieve exact name as per language?
Thank you!
Actually, the method has "done the right thing" for you!
It encodes non-ASCII characters so that it can be valid in all of the cases and transmit over the Internet. If you put your temp variable in an URL as a parameter, you will get your correct result at server side. That's what UrlEncode means for. Here your question is not a problem at all.
So please have a look at this link for further reading to understand about URL Encoding: http://www.w3schools.com/tags/ref_urlencode.asp
If you input that Russian word to the "URL Encoding Functions" part in the page I have given, it will return the same result as Web.HttpUtility.UrlEncode method does.
Can anyone help me how to achieve exact name as per language?
In short: not with that method, but it might depend on what is your exact goal.
In details:
In general URIs as defined by RFC 3986 (see Section 2: Characters) may contain any of the following characters: ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-._~:/?#[]#!$&'()*+,;=. Any other character needs to be encoded with the percent-encoding (%hh).
This is why UrlEncode produces
UrlEncode("Jewelry") -> "Jewelry"
UrlEncode("ювелирные изделия") -> "%d1%8e%d0%b2%d0%b5%d0%bb%d0%b8%d1%80%d0%bd%d1%8b%d0%b5+%d0%b8%d0%b7%d0%b4%d0%b5%d0%bb%d0%b8%d1%8f"
The string of "ювелирные изделия" contains characters that are not allowed in a URL as per RFC 3986.
Today, modern browsers could work with UTF-8 in URL it might be not necessary to use UrlEncode(). See example: http://jsfiddle.net/ybgt96ms/

Enter UTF-32 string in UTF-8 table

I'm creating a web in ASP.NET (C#), and the tables of my database are UTF-8.
Also I've a register form with fields as "username"
Can a person enter a UTF-32 string in the username field and cause an error? How solve the problem? These UTF-32 characters has more than 0 characters (stringLenght bypassed).
You have to look at the whole chain that the data passes. what input do you have, how are the characters transported, which encoding has your api and so on....
UTF-32 is just another "presenation" of UTF-8 for more details i strongly recomment joel spolsky post on that The Absolute Minimum Every Software Developer Absolutely, Positively Must Know About Unicode and Character Sets

Special unicode question mark characters in database table

Firstly anyone who reads this and response, thanks for your assistance.
I'm having a problem where I have a site (primarily in English), with many translations for different language. I have a database which stores these translations. Unfortunately one of the language seems to be populated with question mark characters between each general character. Because of this, any text which contains these characters wont show up in IE.
Is there any SQL statements that will seek these characters out and remove them? There's a find/replace option, but I can't seem to find a rule that applies.
Thanks for any help you can give.
As an example, this is how text shows in a table:
�i�O�N� �k�i�t� �d�e� �s�u�p�p�o�r�t� �V�é�l�o� - which stops it showing IE.
Removing these as below will show it in IE:
iON kit de support Vélo
Any idea how I go about this?
Thanks :)
Your translation database contains mangled data that has come from misinterpreting UTF-16-encoded input as ISO-8859-1 (or the closely related Windows code page 1252; you can't tell the difference from the example data).
You could attempt to undo the damage by extracting the data, encoding it back to what is hopefully the original set of bytes, and re-decoding it, then inserting it back into the database. For example in PHP:
$mangled = "i\0O\0N\0 \0k\0i\0t\0 \0d\0e\0 \0s\0u\0p\0p\0o\0r\0t\0 \0V\0\xE9\0l\0o\0"
$fixed = iconv('utf-16le', 'utf-8', $mangled)
# "iON kit de support V\xC3\xA9lo"
but it would be best to go back to the original input data and re-import it properly really.
Just removing zero bytes from a UTF-16-encoded bytes string (str_replace("\0", '', $mangled)) isn't really fixing it, it would work for the ASCII characters (U+0000–U+007F) but you would end up with ISO-8859-1 bytes for characters U+0080–U+00FF (more usually you would want UTF-8) and any other characters outside that range would remain unreadable nonsense.

Cryptoanalysis: Howto find the password out of several Hex-Values which are XOR encrypted with the same password?

I am pretty unsure if it might be possible to find the password out of several Hex-Values which are XOR encrypted all with the same password?
For example these are some HEX values all XOR encrypted with the same HEX password which has exactly the same length as these values:
a0c91eab4f88c644433311f88b733655c3d03148c25b375123545d8fb3fe7ec7
b885f3cb8f529670040f3e6b15afa84a1a85ace03b108d3b410bc17747352bc3
77d147fdf263471fdfb756c436c1b86911de0a1d688997cfcabc5f6d34a6e045
464c506a68b73f4004e553b215c41ca9ec45c1200c4072ee940596e6760c2007
860a2f619063990663d3fc15d149e6baec423f40d6dd6d5c714ae373cee05985
188c1720cacc341cda9642feecfb05d89af2fe0e5e4bf560f1b85eec6a5b99e8
c3c9271bcd0a295276f9fd1bca172c4be45d3bdfc437992cfdd4a6914d03bdfa
Has anyone around here an idea how to solve that problem?
#phs and #Kerrek SB
Thanks for your response. I would really like to add an answer to your comments but unfortunately I am unable because the comment link does not work as of this JavaScript-Error as it seems. Not sure what that is all about.
Error: missing ) after condition
Source File: http://cdn.sstatic.net/js/full.js?v=ea83ae356357
Line: 1, Column: 242
Source Code:
comment")>-1){var i=g.attr("id").substr("comments-link-".length);var h=c(i);b(i,h,f);return true}return false};return{loadRest:d,init:a,jCommentsDiv:c,showComments:e,fetchComments:b}})();StackExchange.share=(function(){function a(d,b,c){if(!1;''.concat(d, ...
The ciphertext is ASCII (0 ... 254) converted into hex, the password is just a hex string same length as the ciphertext.
#muntoo
Many thanks for the proper formatting of my question. I really would like to know how you managed that because I am not able to see how you did it? This website is really strange in its behaviour, which is quit sad because of all the useful information. I get constantly logged out after clicking on any other message, links don't work, buttons don't work and so on ...
Cheers,
Karl-Uwe
P.S.: Still unable to post a reply to a comment, only the edit link is working as expected :-(
Okay than as this website does not work properly because my NoScript- and Ghostery-AddOn preventing so many foreign domains from loading some kind of weird JavaScript for this website I give up now.
The password I was searching for is 26ffe258d67de61313fc50c55b6afe5f58cbf7bd446354e02947b6c803f13d04
I suppose it's impossible to find it through cryptanalysis because it's an XOR enciphering with random HEX strings. In fact if I would encipher the same text every time with a random string it would be the same the other way round - no chance to decipher it.
Cheers and bye,
Karl-Uwe

How Do I Convert a Byte Stream to a Text String?

I'm working on a licensing system for my application. I'd like to put all licensing information (licensee name, expiration date, and enabled features) into an object, encrypt that object with a private key, then represent the encrypted data as a single text string which I can send via email to my customers.
I've managed to get the encrypted data into a byte stream, but I don't know how to convert that byte stream into a text value -- something that contains no control characters or whitespace. Can anyone offer advice on how to do that? I've been researching the Encoding class, but I can't find a text-only encoding.
I'm using Net 2.0 -- mostly VB, but I can do C# also.
Use a Base64Encoder to convert it to a text string that can be decoded with a Base64Decoder. It is great for representing arbitary binary data in a text friendly manner, only upper and lower case A-Z and 0-9 digits.
BinHex is an example of one way to do that. It may not be exactly what you want -- for example, you might want to encode your data such that it's impossible to inadvertently spell words in your string, and you may or may not care about maximizing the density of information. But it's an example that may help you come up with your own encoding.
I've found Base32 useful for license keys before. There are some C# implementations linked from this answer. My own license code is based on this implementation, which avoids ambiguous characters to make it easier to retype the keys.