473,412 Members | 3,471 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,412 software developers and data experts.

Encrypt accentued characters

Do you know about an encryption script which accepts the accentued
characters. I've found the one below (from WebExpert premade scripts),
but when you encrypt "assurément", then reverse the process, you
retrieve "assurment" : the "é" is gone !

Here is this script (maybe you have another) in an HTML page (simply
copy/paste to see the result) :

<html>
<head>
<!-- JavaScript Couper-coller de ISN Toolbox
Copyright 1996, Infohiway Server Network. L'utilisation restreinte
est accordée (pour un usage personnel ou commercial en autant que le
code de programmation n'est pas vendu directement). De plus, cet avis
doit être présent dans un endroit quelconque de votre document HTML.
Un hyperlien vers http://www.infohiway.com sera toujours apprécié,
mais n'est nullement nécessaire. ;-) -->
<script language="JavaScript">
<!-- Begin
/* Même si la chaîne "cs" est en ordre ASCII ci-dessous, vous pouvez la
"mélanger" si vous voulez
compliquer des tentatives de décryption. */
bs="\\ ";
cs=' !"#$%&';
cs+="'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRS"
+"TUVWXYZ^[_]'abcdefghijklmnopqrstuvwxyz{|}~\t\r\n"+bs;
cm=0;
cm1=0;
cflg="";
/* Même si cet exemple has été préparé en utilisant un paradigme de 4
bits,
vous pouvez le changer pour un à 2, 3 ou 5 bits.
Par exemple, un paradigme à 2 bits ressemblerait à ceci:
four="00 01 10 11";
fourletter="a b c d";
Et le code dans les fonctions d'encryption et de décryption ci-
dessous devraient
être modifiées pour réfléter ce changement. Il y a des
commentaires aux endroits appropriés.
ATTENTION: N'utilisez pas un espace comme caractère d'impression
dans la construction de la
variable "sixletter". Voici d'autres exemples possibles:
sixletter="A B C D E F G H "
+"I J K L M N O P ";
sixletter=". , / ' | _ ( ~ "
+"! @ ^ * - : ; ? "; */

sixteen="0000 0001 0010 0011 0100 0101 0110 0111 "
+"1000 1001 1010 1011 1100 1101 1110 1111 ";
sixletter="; . * , x ( i : "
+"_ - ^ < > ' ~ = ";

function samp(){
// En premier, prenons les 2 chaînes
ls="";
ls1="";
kwd=document.ex1.key.value;
kwdpd=kwd;
msg=document.ex1.ps.value;
// étendons la clé pour être assez longue pour le message
if (cflg==0){
sl=msg.length;
}
else{
sl=msg.length/2;
}
while (kwd.length<sl){
kwd+=kwdpd;
}
document.ex1.ps.value="Je suis en train de convertir la clé et le
message...";
if (cflg!=1){
setTimeout("samp2()",1000);
}
else{
setTimeout("decryp()",1000);
}
}

function samp2(){
// Maintenant, conversion des 2 chaînes en binaire
for (var i=0;i<msg.length;i++){
chk=kwd.charAt(i);
cmk=cs.indexOf(chk)+32;
chm=msg.charAt(i);
cmm=cs.indexOf(chm)+32;
for (var j=7;j>-1;j--){
c=Math.pow(2,j);
if (cmk>=c){
cmk=cmk-c;
ls+="1";
}
else{
ls+="0";
}
if (cmm>=c){
cmm=cmm-c;
ls1+="1";
}
else{
ls1+="0";
}
}
}
document.ex1.ps.value="Je suis en train d'encrypter le message...";
setTimeout("samp3()",1000);
}

function samp3(){
// Maintenant, on converti les bits en utilisant la clé
ls2="";
ls4="";
for (var i=0;i<ls1.length;i++){
ch=ls.charAt(i);
ch1=ls1.charAt(i);
if (ch=="0"){
if (ch1=="0"){
ch1="1";
}
else{
ch1="0";
}
}
ls2+=ch1;
}
/* Si un paradigme de longeur différent est utilisé, changez la boucle
ci-dessous */
for (var i=0;i<ls2.length;i=i+4){
ls3=ls2.substring(i,i+4);
y=sixteen.indexOf(ls3);
ls4+=sixletter.charAt(y);
}
document.ex1.ps.value=ls4;
}

function decryp(){
// Converti le mot clé encore une fois
ls="";
for (var i=0;i<kwd.length;i++){
chk=kwd.charAt(i);
cmk=cs.indexOf(chk)+32;
for (var j=7;j>-1;j--){
c=Math.pow(2,j);
if (cmk>=c){
cmk=cmk-c;
ls+="1";
}
else{
ls+="0";
}
}
}
document.ex1.ps.value="Je suis à décrypter le message...";
setTimeout("decryp1()",1000);
}

function decryp1(){
/* Ensuite, on ramène le message de 4 bits à 8 bits.
Si un paradigme de longeur différent est utilisé, changez la
boucle ci-dessous */
ls1="";
for (var i=0;i<msg.length;i++){
ls3=msg.charAt(i);
y=sixletter.indexOf(ls3);
ls1+=sixteen.substring(y,y+4);
}
// Ensutie on converti les bits en utilisant la clé
ls2="";
ls4="";
for (var i=0;i<ls1.length;i++){
ch=ls.charAt(i);
ch1=ls1.charAt(i);
if (ch=="0"){
if (ch1=="0"){
ch1="1";
}
else{
ch1="0";
}
}
ls2+=ch1;
}
for (var i=0;i<ls2.length;i=i+8){
ls3=ls2.substring(i,i+8);
y=parseInt(ls3,2);
ls4+=cs.charAt(y-32);
}
document.ex1.ps.value=ls4;
}

// End -->
</script>
</head>
<body>
<div align="center">
<TABLE BORDER=0 WIDTH=500>
<TR><TD ALIGN=CENTER><FONT face="Helvetica,Arial,Geneva"><B>Une simple
Encryption utilisant un déplacage de bit</B></FONT><HR NOSHADE></TD>
</TR>
<TR><TD><FONT face="Helvetica,Arial,Geneva">
<FORM NAME="ex1">
<B>Premièrement: </B>Coller ou inscriver votre clé, mot-clé ou phrase-
clé ici:
<BR><INPUT TYPE="password" NAME="key" VALUE="" SIZE=84>
<P><B>Deuxièmement: </B>Coller ou inscriver votre message à encrypter:
<BR><TEXTAREA NAME="ps" ROWS=10 COLS=75 WRAP=VIRTUAL></TEXTAREA>
<BR><B>Troisièment: </B> <INPUT TYPE="button" NAME="but" VALUE="
Encrypter " onClick="cflg=0;samp()">
<BR><B>Quatrièment: </B> <INPUT TYPE="button" NAME="but1" VALUE="
Décrypter " onClick="cflg=1;samp()"></FORM>
<P>Ce script supporte également de multiples (récursive) encryptions
utilisant une même ou différente clé, mot-clé ou phrase-clé pour chaque
itération. Cependant, la taille du message, doublera à chaque
encryption.</FONT><HR NOSHADE></TD></TR>
</TABLE>
</div>
</body>
</html>
Nov 6 '05 #1
3 1705
JellyON wrote:
Do you know about an encryption script which accepts the accentued
characters. I've found the one below (from WebExpert premade scripts),
but when you encrypt "assurément", then reverse the process, you
retrieve "assurment" : the "é" is gone !


One way to preserve this character is to apply escape() before encryption
and to apply unescape() after description.
JW
Nov 6 '05 #2
Janwillem Borleffs wrote:
One way to preserve this character is to apply escape() before
encryption and to apply unescape() after description.


Obviously, this should read:

One way to preserve this character is to apply escape() before
encryption and to apply unescape() after *decryption*.
JW
Nov 6 '05 #3
In article <43***********************@news.euronet.nl>, jw@jwscripts.com
says...
Janwillem Borleffs wrote:
One way to preserve this character is to apply escape() before
encryption and to apply unescape() after description.


Obviously, this should read:

One way to preserve this character is to apply escape() before
encryption and to apply unescape() after *decryption*.
JW


Hum, effectively. I'll try asap. Thanks Janwillem
Nov 6 '05 #4

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

Similar topics

3
by: Russ Reynolds | last post by:
SQL Server 2000: ######################################################## I run the following as a normal query from Analyzer: ######################################################## SELECT...
14
by: Andrew Poulos | last post by:
I've built a javascript driven quiz. Given that client-side scripting is not secure, is there a way to "obscure" answers so that they are unavailable to the casual viewer? For example, If I have an...
2
by: Chris | last post by:
Has anyone got a function (or class) that will take a string and encrypt it into printable characters, then a similar function that will decrypt it again, without the need to call external programs...
2
by: Salman | last post by:
When I run the below method with a 64 character string as input such as: sr.Encrypt("1234567890123456789012345678901234567890123456789012345678904444"); I get square boxes as my output, which...
20
by: Drebin | last post by:
It's a long story really, but the bottom line is we need to encrypt or obfuscate a clear-text 9-digit SSN/taxpayer ID into something less than 21 characters. It doesn't need to be super-secure,...
4
by: stuckish | last post by:
Im trying to encrypt a string in asp.net. Post the encrypted string thru a form. Recive the encrypted string on a classic asp page and decrypt it there. I get a error saying "Padding is invalid...
1
by: JellyON | last post by:
Hi. I'm trying to use the encryption script delivered with the HTML Editor : WebExpert 6. This script doesn't allows accentued characters. Then, sometimes ago I asked for a way to modify-it and...
1
by: Y Store Tools | last post by:
I've just started playing with mcrypt for encryption but not sure if I'll need to write my own. Basically I don't need anything advanced for protection but want to mask the data so it's not easily...
0
by: Derek Hart | last post by:
I will have security rights stored in XML data, and I just need the content of elements and/or attributes to be encrypted. When the dotnet application reads in the information, it would run a...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
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,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
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...
0
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...
0
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,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

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.