473,699 Members | 2,579 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

[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",$ciphe r) ;
$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",$ciphe r) ;
$count+=1 ;
if ($count % 5 == 0) {print " ";}
if ($count %60 == 0) {print "\n" ; }
}
}
print "\n" ;

--
Best Regards
Piotr Turkowski
Jul 19 '05 #1
4 2522
"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.programmin g
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.programmin g.

--
Chuck F (cb********@yah oo.com) (cb********@wor ldnet.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
1944
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) Why can I download Access DBs from FTP sites in the default mode (icString??) and everything looks OK (eg, file/byte size, functionality, etc), when MSDN shows a completely different method for binary downloads? I thought Access DBs were binary...
31
4792
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 great for pattern matching, text processing, and automated testing. Our company is really fixated on risk managnemt and the only way I can do enough testing without working overtime (which some people have ended up doing) is by automating my...
11
1161
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 get endless amount of results from the newsgroup police complaining about posters cross posting to many newsgroups as this very message is doing. So to those at Microsoft, and since posting your form results to another page is very very...
0
9739
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. I need it to be compiled with threads. Anyone have any wisdom on how best to do this? Here's a transcript of my latest attempt. It's long; you might want to skip to the bottom, where I try "make" and the fatal errors start happening.
21
34413
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 obvious of which is the sharing of files. For example, you upload images to a server to share them with other people over the Internet. Perl comes ready equipped for uploading files via the CGI.pm module, which has long been a core module and allows users...
97
2731
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 Reviews (2008 Jan 10) by Stephen Wolfram http://blog.wolfram.com/2008/01/10/ten-thousand-hours-of-design-reviews/ The issue is fitting here today, in our discussion of “closure” terminology recently, as well the jargons “lisp 1 vs lisp2”...
0
8686
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
8615
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9173
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
9033
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...
0
8882
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
7748
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...
1
6533
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5872
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4375
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...

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.