A preserved archive of the Logical Gamers community forums, 2009-2025. The original threads and posts, served read-only. Registration, posting and private messages are gone for good.

[C#] Offset Encryption

1.1k views · started by Chad ·
#1
[C#] Offset Encryption
I got bored in my IT Class one day and wrote this up. Figured I'd share. The only thing I can think of to add is the, if a letter is capitalized, it returns capitalized. Other then that, numbers work too!

 public static String Offset(String toEncrypt, Int32 offsetValue)
{
String alphabet = "abcdefghijklmnopqrstuvwxyz";
String newEncryption = String.Empty;

foreach (Char character in toEncrypt)
{
if (isNumeric(character.ToString()) == false)
{
Int32 curPosition = 0;
for (int i = 0; i < alphabet.Length; i++)
{
if (alphabet[i] == character)
{
curPosition = i;
break;
}
}

Int32 newPosition = curPosition + offsetValue;
if (newPosition >= alphabet.Length)
newPosition = (curPosition + offsetValue) - alphabet.Length;

newEncryption += alphabet[newposition];
}
else
{
newEncryption += Int32.Parse(character.ToString()) + offsetValue;
}
}
return newEncryption;
}
[/newposition][/i]


Forgot! The isNumeric Function.

    public static Boolean isNumeric(String Value)
{
double num;
bool isNum = double.TryParse(Value, out num);
return true != false ? isNum : true;
}
#2
Hey, it's you. Although the final line of your isNumeric function is lulsy. Seeing as how true is never going to equal false, you're obviously always going to return isNum, so why didn't you just use:

		public static Boolean isNumeric(String Value)
{
double num;
return double.TryParse(Value, out num);
}


lol.
#3
Artificial wrote:
Hey, it's you. Although the final line of your isNumeric function is lulsy. Seeing as how true is never going to equal false, you're obviously always going to return isNum, so why didn't you just use:

		public static Boolean isNumeric(String Value)
{
double num;
return double.TryParse(Value, out num);
}


lol.


Artificial - decomposing bad code since 2005.

Edit: Looks like someone doesn't know how to use ternary operators properly, lol.

http://forum.logicalgamers.com/source-codes/39080-c-check-negative.html

Nice contribution though, OP. Stay active more.
#4
Either way, it still worked. Thanks Arti.

As for activity, I'm currently bridging internet from my friends laptop. I haven't had internet in roughly 4 months.
#5
Chad wrote:
Either way, it still worked. Thanks Arti.

As for activity, I'm currently bridging internet from my friends laptop. I haven't had internet in roughly 4 months.


Oh man, what happened? Just no money to pay for internet bills?

Protip: Start wardriving to find open networks around you, and then learn about cracking WEP, WPA, and WPA2 so you can just have internet wherever you are. It's surprising how many open or insecure networks there are all around you.
#6
Oh man, what happened? Just no money to pay for internet bills?

Protip: Start wardriving to find open networks around you, and then learn about cracking WEP, WPA, and WPA2 so you can just have internet wherever you are. It's surprising how many open or insecure networks there are all around you.


Only that's not always reliable. If the network is sufficiently secured then his shot at cracking is low.
#7
Also, illegal.
#8
Oh man, what happened? Just no money to pay for internet bills?

Protip: Start wardriving to find open networks around you, and then learn about cracking WEP, WPA, and WPA2 so you can just have internet wherever you are. It's surprising how many open or insecure networks there are all around you.


I don't have a Laptop or a network card in my desktop or else I would've done that a long time ago. There are a ton of networks around. My favorite, the DMV and DPS. :3