473,386 Members | 1,621 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,386 software developers and data experts.

[crosspost] Perl -> C

Hi!
I've got some code in Perl and I have to have it in C, but my knowlege
of Perl is < 0 :-(, so I need your help. here's the code. Thanks in advance.

decrypt.pl

#!/usr/local/bin/perl
$keyword=$ARGV[0] ;
@key=split(//,$keyword) ;
$period=length($keyword) ;
$count=0 ;
while(<STDIN>) {
chop ;
tr/a-z/A-Z/ ;
tr/A-Z//cd ;
@line=split(//) ;
foreach $i (@line) {
$cipher=ord($i)-ord($key[$count % $period])+65;
if ($cipher<65) {$cipher+=26 ; }
print pack("C",$cipher) ;
$count+=1 ;
if ($count % 5 == 0) {print " ";}
}
print "\n" ;
}
print "\n" ;
and encrypt.pl

#!/usr/local/bin/perl
$keyword=$ARGV[0] ;
$keyword=~tr/a-z/A-Z/ ;
@key=split(//,$keyword) ;
$period=length($keyword) ;
$count=0 ;
while(<STDIN>) {
chop ;
tr/a-z/A-Z/ ;
tr/A-Z//cd ;
@line=split(//) ;
foreach $i (@line) {
$cipher=ord($i)+ord($key[$count % $period])-65;
if ($cipher>=91) {$cipher-=26 ; }
print pack("C",$cipher) ;
$count+=1 ;
if ($count % 5 == 0) {print " ";}
if ($count %60 == 0) {print "\n" ; }
}
}
print "\n" ;

--
Best Regards
Piotr Turkowski
Jul 19 '05 #1
4 2513
"Piotr Turkowski" <pi***@ust.tke.pl> wrote in message
news:bv**********@nemesis.news.tpi.pl...
Hi!
I've got some code in Perl and I have to have it in C, but my knowlege
of Perl is < 0 :-(, so I need your help. here's the code. Thanks in advance.
decrypt.pl


[snip code]

Well, Perl's OT in c.l.c., and C's OT in c.l.p., so
what's a body to do?? :-)

I suggest you ask someone in the Perl group to explain
in English what the Perl code does, then you can write
the C code from the English specification. If you get
stuck, post the functional description to the C group
along with your code, and we can offer ideas and suggestions,
etc.

HTH,
-Mike
Jul 19 '05 #2
Użytkownik Mike Wahler napisał:
Well, Perl's OT in c.l.c., and C's OT in c.l.p., so
what's a body to do?? :-)
And this is the very true truth :) (sorry for my Engilsh ;-)
I suggest you ask someone in the Perl group to explain
in English what the Perl code does, then you can write
the C code from the English specification. If you get
stuck, post the functional description to the C group
along with your code, and we can offer ideas and suggestions,
etc.


OK, so here is what i want to create.
1. Text editor with GUI, which would have an opportunity to
encypt/decrypt text with Vigerene Cipher.
2. Options: saving/opening files :)
3. New file type: *.vig (encrypted file)
4. Two langauge program (polish/english) I can translate it :D
5. Changing font, size of text, just for display (you know what i mean)
*6. Registration form. Shareware, or sth. Someone send me his 'name' i
generate 'key' and then program is fully functionally. If not, the
program can encrypt/decrypt only 20 chars, and can't save and open
encrypted file.

*at the end
So, I'm a real noob. I don't want you to write this program, I just need
your help :). So guide me, what I shuold create at the beggining. Mayby
some examples of text editor ?

best regards
Peter
Jul 19 '05 #3

On Sun, 25 Jan 2004, Piotr Turkowski wrote in comp.lang.c:

Użytkownik Mike Wahler napisał:
I suggest you ask someone in the Perl group to explain
in English what the Perl code does, then you can write
the C code from the English specification. If you get
stuck, post the functional description to the C group
along with your code, and we can offer ideas and suggestions,
etc.
OK, so here is what i want to create.
1. Text editor with GUI, which would have an opportunity to
encypt/decrypt text with Vigerene Cipher.


Writing full-screen editors or other GUIs is off-topic in this
newsgroup, where we discuss standard C only. Standard C has no
support for GUIs or screen manipulation. (And probably off-topic
in comp.lang.perl, too, but I don't read that group.)
As for Vigenere solvers, you can search Google or Google Groups
for C source code. J.W. Stumpel wrote some decent Vigenere code
a while back, for instance. Given an encrypted text, it returns
its best guess as to the key and the original plaintext. If you
want help *writing* a Vigenere program, ask in comp.programming
or sci.crypt. If you want help *understanding* Stumpel's code,
or anyone else's C code, *then* c.l.c will be happy to help you.
2. Options: saving/opening files :)
This is topical here; look up 'fopen' and 'fprintf' in the
standard C library.
3. New file type: *.vig (encrypted file)
Most operating systems let you call your files whatever you
want. The details of your particular OS are off-topic in
comp.lang.c, which discusses a programming language, not an OS.
4. Two langauge program (polish/english) I can translate it :D
Polish, as it uses a different alphabet (and one not actually
guaranteed to get much support from the C language), might require
a bit of work. But not too much.
5. Changing font, size of text, just for display (you know what i mean)
Not really. "Font" in a program that deals with encryption and
decryption of text? What possible use could that serve?
*6. Registration form. Shareware, or sth. Someone send me his 'name' i
generate 'key' and then program is fully functionally. If not, the
program can encrypt/decrypt only 20 chars, and can't save and open
encrypted file.
IMNSHO, if you can't write your program on your own, without coming
to Usenet for spoon-feeding, you don't deserve to get any money for
the final product (as it won't be *yours*, but belong to whoever
actually wrote the relevant code in the first place). Anyway,
philosophical objections aside, nobody is going to pay for a program
they can get for free anyway, unless you're planning to sell technical
support for the Vigenere cipher. :-D
So, I'm a real noob. I don't want you to write this program, I just need
your help :). So guide me, what I shuold create at the beggining. Mayby
some examples of text editor ?


pico, vim, emacs. In fact, although it's off-topic here, I bet
there's a way to add a "mod" to emacs so that it can do Vigenere
ciphering on its own. I'm sure a Polish version of emacs already
exists, probably even with a spell-checker and all those bells and
whistles. Try a group devoted to emacs (possibly in the gnu.*
hierarchy?).

-Arthur

Jul 19 '05 #4
Mike Wahler wrote:
"Piotr Turkowski" <pi***@ust.tke.pl> wrote in message
I've got some code in Perl and I have to have it in C, but my
knowlege of Perl is < 0 :-(, so I need your help. here's the
code. Thanks in advance.


[snip code]

Well, Perl's OT in c.l.c., and C's OT in c.l.p., so
what's a body to do?? :-)


Maybe go somewhere more tolerant, such as comp.programming.

--
Chuck F (cb********@yahoo.com) (cb********@worldnet.att.net)
Available for consulting/temporary embedded and systems.
<http://cbfalconer.home.att.net> USE worldnet address!
Jul 19 '05 #5

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

Similar topics

0
by: Laphan | last post by:
I know this is a crosspost, but I need to know which is the best one for posting INET FTP queries, so that I'm not cross-posting in future. Now that I've posted could somebody let me know: 1)...
31
by: surfunbear | last post by:
I've read some posts on Perl versus Python and studied a bit of my Python book. I'm a software engineer, familiar with C++ objected oriented development, but have been using Perl because it is...
11
by: anon | last post by:
Dear Microsoft: In your new ASP.NET 2.0 page model of being able to crosspost to another page, it would seem that if you were to type that word in Google, "crosspost" or "cross post", you will...
0
by: Kirt Loki Dankmyer | last post by:
So, I download the latest "stable" tar for perl (5.8.7) and try to compile it on the Solaris 8 (SPARC) box that I administrate. I try all sorts of different switches, but I can't get it to compile....
21
KevinADC
by: KevinADC | last post by:
Note: You may skip to the end of the article if all you want is the perl code. Introduction Uploading files from a local computer to a remote web server has many useful purposes, the most...
97
by: xahlee | last post by:
I'd like to introduce a blog post by Stephen Wolfram, on the design process of Mathematica. In particular, he touches on the importance of naming of functions. • Ten Thousand Hours of Design...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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...

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.