• Log InLog In
  • Register
Liquid`
Team Liquid Liquipedia
EDT 12:29
CEST 18:29
KST 01:29
  • Home
  • Forum
  • Calendar
  • Streams
  • Liquipedia
  • Features
  • Store
  • EPT
  • TL+
  • StarCraft 2
  • Brood War
  • Smash
  • Heroes
  • Counter-Strike
  • Overwatch
  • Liquibet
  • Fantasy StarCraft
  • TLPD
  • StarCraft 2
  • Brood War
  • Blogs
Forum Sidebar
Events/Features
News
Featured News
Code S Season 1 - RO12 Group A: Rogue, Percival, Solar, Zoun13[ASL21] Ro8 Preview Pt1: Inheritors16[ASL21] Ro16 Preview Pt2: All Star10Team Liquid Map Contest #22 - The Finalists22[ASL21] Ro16 Preview Pt1: Fresh Flow9
Community News
RSL Revival: Season 5 - Qualifiers and Main Event7Code S Season 1 (2026) - RO12 Results02026 GSL Season 1 Qualifiers25Maestros of the Game 2 announced92026 GSL Tour plans announced15
StarCraft 2
General
Code S Season 1 - RO12 Group A: Rogue, Percival, Solar, Zoun Code S Season 1 (2026) - RO12 Results Team Liquid Map Contest #22 - The Finalists Blizzard Classic Cup @ BlizzCon 2026 - $100k prize pool MaNa leaves Team Liquid
Tourneys
RSL Revival: Season 5 - Qualifiers and Main Event GSL Code S Season 1 (2026) SC2 INu's Battles#15 <BO.9 2Matches> WardiTV Spring Cup SEL Masters #6 - Solar vs Classic (SC: Evo)
Strategy
Custom Maps
[D]RTS in all its shapes and glory <3 [A] Nemrods 1/4 players [M] (2) Frigid Storage
External Content
The PondCast: SC2 News & Results Mutation # 523 Firewall Mutation # 522 Flip My Base Mutation # 521 Memorable Boss
Brood War
General
Why there arent any 256x256 pro maps? Pros React To: Leta vs Tulbo (ASL S21, Ro.8) Missed out on ASL tickets - what are my options? ASL21 General Discussion BGH Auto Balance -> http://bghmmr.eu/
Tourneys
[Megathread] Daily Proleagues Escore Tournament StarCraft Season 2 [BSL22] RO16 Group Stage - 02 - 10 May [ASL21] Ro8 Day 2
Strategy
Fighting Spirit mining rates Simple Questions, Simple Answers What's the deal with APM & what's its true value Any training maps people recommend?
Other Games
General Games
Nintendo Switch Thread Stormgate/Frost Giant Megathread Daigo vs Menard Best of 10 Dawn of War IV Diablo IV
Dota 2
The Story of Wings Gaming
League of Legends
G2 just beat GenG in First stand
Heroes of the Storm
Simple Questions, Simple Answers Heroes of the Storm 2.0
Hearthstone
Deck construction bug Heroes of StarCraft mini-set
TL Mafia
Vanilla Mini Mafia Mafia Game Mode Feedback/Ideas TL Mafia Community Thread Five o'clock TL Mafia
Community
General
European Politico-economics QA Mega-thread US Politics Mega-thread Russo-Ukrainian War Thread 3D technology/software discussion Canadian Politics Mega-thread
Fan Clubs
The IdrA Fan Club
Media & Entertainment
[Manga] One Piece Anime Discussion Thread [Req][Books] Good Fantasy/SciFi books Movie Discussion!
Sports
2024 - 2026 Football Thread McBoner: A hockey love story Formula 1 Discussion
World Cup 2022
Tech Support
streaming software Strange computer issues (software) [G] How to Block Livestream Ads
TL Community
The Automated Ban List
Blogs
Sexual Health Of Gamers
TrAiDoS
lurker extra damage testi…
StaticNine
Broowar part 2
qwaykee
Funny Nicknames
LUCKY_NOOB
Iranian anarchists: organize…
XenOsky
Customize Sidebar...

Website Feedback

Closed Threads



Active: 1256 users

The Big Programming Thread - Page 597

Forum Index > General Forum
Post a Reply
Prev 1 595 596 597 598 599 1032 Next
Thread Rules
1. This is not a "do my homework for me" thread. If you have specific questions, ask, but don't post an assignment or homework problem and expect an exact solution.
2. No recruiting for your cockamamie projects (you won't replace facebook with 3 dudes you found on the internet and $20)
3. If you can't articulate why a language is bad, don't start slinging shit about it. Just remember that nothing is worse than making CSS IE6 compatible.
4. Use [code] tags to format code blocks.
teamamerica
Profile Blog Joined July 2010
United States958 Posts
Last Edited: 2015-02-28 20:44:28
February 28 2015 20:40 GMT
#11921
On March 01 2015 05:32 Manit0u wrote:
Show nested quote +
On March 01 2015 05:14 teamamerica wrote:
They have a few different components - salt, iv, and actual passphrase used to generate key. I'm wondering how important it is to keep all of that data private. I was going to simply hardcode salt into code(choose 8 random bytes), and also store the IV with the encrypted text.


http://security.stackexchange.com/questions/17421/how-to-store-salt

The chosen answer is very informational and a good read in itself. Also, it's important to have a unique salt for each encryption, rather than having a single global salt.


Hi, thanks for posting that. However - and maybe because that is only focusing on storing password (so only 1 way transformation needed), it doesn't discus storing an IV, which is used by the actual symmetric crypto part of storage (from what I understand of my code -- passphrase => key (using KDF), cleartext => key => ciphertext.

From what I've googled, IV can be stored in cleartext to (they compare it to storing salt for hash, here I guess we have both because we use both kdf and aes).

Wondering if anyone had other exp - also - beyond that, anything glaringly wrong with my code?

I guess I shouldn't hard code the salt but honestly does it make a difference? This isn't an online application where adversary is sending me queries and I'm responding.

edit: in response to your edit
"Also, it's important to have a unique salt for each encryption, rather than having a single global salt."

I only use salt to generate one thing - the key. So really, there is only one encryption going on that uses it I guess. Unless I'm not following something?

RIP GOMTV. RIP PROLEAGUE.
nunez
Profile Blog Joined February 2011
Norway4003 Posts
February 28 2015 20:57 GMT
#11922
the this keyword is a pointer to the object on which a member function is called.
in your example member function being called is character::character(), and the type of this
is character*.

when you apply the dereference operator * on a pointer, you obtain an l-value of the object that is pointed to.
in your example the type of the result of dereferencing this (aka when you write *this) is character&.

addObjectToList takes an argument of type character*, thus you need to pass this and not *this.

illustration:

type* pointer_to_object = new type();
type* another_pointer_object = pointer;
type& reference_to_objeft = *pointer;
type copy_of_object=*pointer;
conspired against by a confederacy of dunces.
Blisse
Profile Blog Joined July 2010
Canada3710 Posts
February 28 2015 21:01 GMT
#11923
On March 01 2015 05:36 sabas123 wrote:
+ Show Spoiler +

class character;
std::vector<characater>objectList;

class character{
character();
};

character::character(){
addObjectToList(*this);
}

addObjectToList(character *obj){
objectList.push_back( character *obj);
}

error:: expecting primal type before '*'


sorry about my terrible post, I hope this clears some stuff up.


Lots of errors in the code there, make sure you use code tags too next time to keep the formatting.

keyword this is a pointer to the current instance of the object
*this dereferences that pointer to the actual instance
your addObjectToList method takes in a character*, but you pass in a dereferenced this, or the actual object
you have a syntax error with push_back( character *obj), which doesn't make sense since you don't need to specify the type there again (the type is already known by the method definition)
the addObjectToList definition is below its first usage, and you haven't forward declared it earlier, so it wouldn't compile
your character constructor was declared private, you need to set it as public

may be more that i missed and i dont know if my code compiles


class character;
std::vector<character> objectList;

class character{
public:
character();
};

addObjectToList(character obj){
objectList.push_back(obj);
}

character::character() {
addObjectToList(*this);
}

There is no one like you in the universe.
nunez
Profile Blog Joined February 2011
Norway4003 Posts
February 28 2015 21:56 GMT
#11924
i was assuming he wanted to store pointers to instantiations,
and not copies of instantiations.
conspired against by a confederacy of dunces.
Blisse
Profile Blog Joined July 2010
Canada3710 Posts
March 01 2015 08:05 GMT
#11925
oo didn't see that earlier post



class character;
std::vector<character*> objectList;

class character{
public:
character();
};

addObjectToList(character* obj){
objectList.push_back(obj);
}

character::character() {
addObjectToList(this);
}
There is no one like you in the universe.
sabas123
Profile Blog Joined December 2010
Netherlands3122 Posts
Last Edited: 2015-03-01 17:24:53
March 01 2015 17:24 GMT
#11926
On March 01 2015 17:05 Blisse wrote:
oo didn't see that earlier post



class character;
std::vector<character*> objectList;

class character{
public:
character();
};

addObjectToList(character* obj){
objectList.push_back(obj);
}

character::character() {
addObjectToList(this);
}

90p;0p;-0p;-[=0p;-[=90p;0p;-0p;-[=0p;-[=90p;0p;-0p;-[=0p;-[=90p;0p;-0p;-[=0p;-[=90p;0p;-0p;-[=0p;-[=90p;0p;-0p;-[=0p;-[=

the result of alot of face keyboarding over this code.

thanks alot!

btw you forgot to add a pointer too bjectList.push_back(obj);
The harder it becomes, the more you should focus on the basics.
Khalum
Profile Joined September 2010
Austria831 Posts
March 01 2015 18:53 GMT
#11927
On March 02 2015 02:24 sabas123 wrote:
Show nested quote +
On March 01 2015 17:05 Blisse wrote:
oo didn't see that earlier post



class character;
std::vector<character*> objectList;

class character{
public:
character();
};

addObjectToList(character* obj){
objectList.push_back(obj);
}

character::character() {
addObjectToList(this);
}

90p;0p;-0p;-[=0p;-[=90p;0p;-0p;-[=0p;-[=90p;0p;-0p;-[=0p;-[=90p;0p;-0p;-[=0p;-[=90p;0p;-0p;-[=0p;-[=90p;0p;-0p;-[=0p;-[=

the result of alot of face keyboarding over this code.

thanks alot!

btw you forgot to add a pointer too bjectList.push_back(obj);


'obj' is a pointer.
sabas123
Profile Blog Joined December 2010
Netherlands3122 Posts
March 01 2015 19:47 GMT
#11928
On March 02 2015 03:53 Khalum wrote:
Show nested quote +
On March 02 2015 02:24 sabas123 wrote:
On March 01 2015 17:05 Blisse wrote:
oo didn't see that earlier post



class character;
std::vector<character*> objectList;

class character{
public:
character();
};

addObjectToList(character* obj){
objectList.push_back(obj);
}

character::character() {
addObjectToList(this);
}

90p;0p;-0p;-[=0p;-[=90p;0p;-0p;-[=0p;-[=90p;0p;-0p;-[=0p;-[=90p;0p;-0p;-[=0p;-[=90p;0p;-0p;-[=0p;-[=90p;0p;-0p;-[=0p;-[=

the result of alot of face keyboarding over this code.

thanks alot!

btw you forgot to add a pointer to objectList.push_back(obj);


'obj' is a pointer.

I had to place an * before the obj in the push_back call otherwise it would wouldn't compile for me.
The harder it becomes, the more you should focus on the basics.
Ropid
Profile Joined March 2009
Germany3557 Posts
March 01 2015 19:57 GMT
#11929
That can't be right if it's code like what's in Blisse's post.
"My goal is to replace my soul with coffee and become immortal."
Khalum
Profile Joined September 2010
Austria831 Posts
Last Edited: 2015-03-01 20:15:47
March 01 2015 20:15 GMT
#11930
On March 02 2015 04:47 sabas123 wrote:
Show nested quote +
On March 02 2015 03:53 Khalum wrote:

[..]
btw you forgot to add a pointer to objectList.push_back(obj);


'obj' is a pointer.

I had to place an * before the obj in the push_back call otherwise it would wouldn't compile for me.


You probably have a vector< character > instead of a vector< character* > ?
Blisse
Profile Blog Joined July 2010
Canada3710 Posts
Last Edited: 2015-03-01 21:49:15
March 01 2015 21:47 GMT
#11931
blasphemous spaces inside the template typename!

make sure you know what's the difference between vector<character*> and vector<character>, and why you're probably talking about using the first one and not the second. nunez has a bit more thorough explanation of what was going wrong up above.
There is no one like you in the universe.
Deleted User 3420
Profile Blog Joined May 2003
24492 Posts
March 02 2015 04:36 GMT
#11932
I am starting to discover that very good programmers must also have very very good organizational skills
meatpudding
Profile Joined March 2011
Australia520 Posts
March 02 2015 04:47 GMT
#11933
On March 02 2015 13:36 travis wrote:
I am starting to discover that very good programmers must also have very very good organizational skills

Perhaps you have uncovered why I am not the best programmer!

Even more important is patience I think. In programming you may end up spending a lot of time doing (Seemingly) very little.
Be excellent to each other.
Manit0u
Profile Blog Joined August 2004
Poland17741 Posts
March 02 2015 06:11 GMT
#11934
On March 02 2015 13:47 meatpudding wrote:
Show nested quote +
On March 02 2015 13:36 travis wrote:
I am starting to discover that very good programmers must also have very very good organizational skills

Perhaps you have uncovered why I am not the best programmer!

Even more important is patience I think. In programming you may end up spending a lot of time doing (Seemingly) very little.


Well, even in the preface of Clean Code they mention that programming is mostly reading and writing, but the reading to writing ratio is roughly 10 to 1. Go figure.
Time is precious. Waste it wisely.
Blisse
Profile Blog Joined July 2010
Canada3710 Posts
Last Edited: 2015-03-02 09:02:15
March 02 2015 08:36 GMT
#11935
spent 3 hours fixing my sass to realize that foundation was being imported after my custom styles, so it would keep overwriting my custom stuff and making me really annoyed that nothing i changed was showing up...
There is no one like you in the universe.
sabas123
Profile Blog Joined December 2010
Netherlands3122 Posts
March 02 2015 09:01 GMT
#11936
On March 02 2015 05:15 Khalum wrote:
Show nested quote +
On March 02 2015 04:47 sabas123 wrote:
On March 02 2015 03:53 Khalum wrote:

[..]
btw you forgot to add a pointer to objectList.push_back(obj);


'obj' is a pointer.

I had to place an * before the obj in the push_back call otherwise it would wouldn't compile for me.


You probably have a vector< character > instead of a vector< character* > ?

your right, thanks for pointing it out
The harder it becomes, the more you should focus on the basics.
Manit0u
Profile Blog Joined August 2004
Poland17741 Posts
Last Edited: 2015-03-02 11:42:42
March 02 2015 11:09 GMT
#11937
I so hate ugly code...

Before:

protected function generatePassword($length = 12)
{
$lowercase = "qwertyuiopasdfghjklzxcvbnm";
$uppercase = "ASDFGHJKLZXCVBNMQWERTYUIOP";
$numbers = "1234567890";
$specialCharacters = "_!?";
$randomCode = "";
mt_srand(crc32(microtime()));
$max = strlen($lowercase) - 1;
for ($x = 0; $x < abs($length / 3); $x++) {
$randomCode .= $lowercase{mt_rand(0, $max)};
}
$max = strlen($uppercase) - 1;
for ($x = 0; $x < abs($length / 3); $x++) {
$randomCode .= $uppercase{mt_rand(0, $max)};
}
$max = strlen($specialCharacters) - 1;
for ($x = 0; $x < abs($length / 3); $x++) {
$randomCode .= $specialCharacters{mt_rand(0, $max)};
}
$max = strlen($numbers) - 1;
for ($x = 0; $x < abs($length / 3); $x++) {
$randomCode .= $numbers{mt_rand(0, $max)};
}

return str_shuffle($randomCode);
}


After:

protected function generatePassword($length = 12)
{
$lowercaseLettersArray = range('a', 'z');
$uppercaseLettersArray = range('A', 'Z');
$numbersArray = range(0, 9);
$specialCharactersArray = array('_', '!', '?');
$randomizedString = '';

$i = abs($length / 3);

while ($i--) {
$randomizedString .= $this->getRandomArrayMember($lowercaseLettersArray);
$randomizedString .= $this->getRandomArrayMember($uppercaseLettersArray);
$randomizedString .= $this->getRandomArrayMember($numbersArray);
$randomizedString .= $this->getRandomArrayMember($specialCharactersArray);
}

return str_shuffle($randomizedString);
}

protected function getRandomArrayMember($array)
{
return $array[array_rand($array)];
}


Edit: Unrelated bonus good read: http://apievangelist.com/2012/01/12/the-secret-to-amazons-success-internal-apis/
Time is precious. Waste it wisely.
berated-
Profile Blog Joined February 2007
United States1134 Posts
March 02 2015 11:32 GMT
#11938
On March 02 2015 20:09 Manit0u wrote:
I so hate ugly code...

Before:

protected function generatePassword($length = 12)
{
$lowercase = "qwertyuiopasdfghjklzxcvbnm";
$uppercase = "ASDFGHJKLZXCVBNMQWERTYUIOP";
$numbers = "1234567890";
$specialCharacters = "_!?";
$randomCode = "";
mt_srand(crc32(microtime()));
$max = strlen($lowercase) - 1;
for ($x = 0; $x < abs($length / 3); $x++) {
$randomCode .= $lowercase{mt_rand(0, $max)};
}
$max = strlen($uppercase) - 1;
for ($x = 0; $x < abs($length / 3); $x++) {
$randomCode .= $uppercase{mt_rand(0, $max)};
}
$max = strlen($specialCharacters) - 1;
for ($x = 0; $x < abs($length / 3); $x++) {
$randomCode .= $specialCharacters{mt_rand(0, $max)};
}
$max = strlen($numbers) - 1;
for ($x = 0; $x < abs($length / 3); $x++) {
$randomCode .= $numbers{mt_rand(0, $max)};
}

return str_shuffle($randomCode);
}


After:

protected function generatePassword($length = 12)
{
$lowercaseLettersArray = range('a', 'z');
$uppercaseLettersArray = range('A', 'Z');
$numbersArray = range(0, 9);
$specialCharactersArray = array('_', '!', '?');
$randomizedString = '';

$i = abs($length / 3);

while ($i--) {
$randomizedString .= $this->getRandomArrayMember($lowercaseLettersArray);
$randomizedString .= $this->getRandomArrayMember($uppercaseLettersArray);
$randomizedString .= $this->getRandomArrayMember($numbersArray);
$randomizedString .= $this->getRandomArrayMember($specialCharactersArray);
}

return str_shuffle($randomizedString);
}

protected function getRandomArrayMember($array)
{
return $array[array_rand($array)];
}


I hope this is only generating passwords of length 4, 8, and 12
Manit0u
Profile Blog Joined August 2004
Poland17741 Posts
March 02 2015 11:47 GMT
#11939
Well, the length variable is deceiving in this case because if length = 12 the generated password will have 16 characters...
Time is precious. Waste it wisely.
berated-
Profile Blog Joined February 2007
United States1134 Posts
Last Edited: 2015-03-02 12:03:08
March 02 2015 12:01 GMT
#11940
On March 02 2015 20:47 Manit0u wrote:
Well, the length variable is deceiving in this case because if length = 12 the generated password will have 16 characters...


Right, my math started to suck at 12 ... anyways, beautiful code isn't just refactored well.. it also makes sense. I'm not sure that totally makes sense. Karma for being a smart ass, I'll rationalize as "2/3 ain't bad".
Prev 1 595 596 597 598 599 1032 Next
Please log in or register to reply.
Live Events Refresh
IPSL
16:00
Ro24 Group E
Ret vs Art_Of_Turtle
Radley vs TBD
Liquipedia
[ Submit Event ]
Live Streams
Refresh
StarCraft 2
LamboSC2 409
Railgan 97
SteadfastSC 91
BRAT_OK 67
Ketroc 51
gerald23 35
StarCraft: Brood War
Britney 32827
Calm 7515
Sea 2512
Horang2 1638
Shuttle 1270
Soma 541
Hyuk 435
EffOrt 416
ggaemo 398
Rush 254
[ Show more ]
hero 171
Nal_rA 143
actioN 84
Hyun 60
sorry 38
Movie 32
Barracks 32
Rock 27
Sharp 25
Hm[arnc] 23
yabsab 15
JulyZerg 14
Terrorterran 11
IntoTheRainbow 10
SilentControl 8
Dota 2
Gorgc4055
qojqva1885
monkeys_forever336
420jenkins231
Heroes of the Storm
Khaldor449
MindelVK8
Other Games
B2W.Neo1601
Beastyqt813
ArmadaUGS361
Hui .174
crisheroes149
KnowMe140
Trikslyr38
Rex18
Organizations
Dota 2
PGL Dota 2 - Main Stream71
StarCraft 2
Blizzard YouTube
StarCraft: Brood War
BSLTrovo
[ Show 18 non-featured ]
StarCraft 2
• iHatsuTV 18
• Adnapsc2 16
• Kozan
• LaughNgamezSOOP
• sooper7s
• AfreecaTV YouTube
• Migwel
• intothetv
• IndyKCrew
StarCraft: Brood War
• Michael_bg 40
• Airneanach38
• STPLYoutube
• ZZZeroYoutube
• BSLYoutube
Dota 2
• WagamamaTV476
League of Legends
• Jankos1825
• Nemesis1721
Other Games
• Shiphtur249
Upcoming Events
BSL
2h 31m
Replay Cast
7h 31m
RSL Revival
17h 31m
herO vs TriGGeR
NightMare vs Solar
uThermal 2v2 Circuit
21h 31m
BSL
1d 2h
IPSL
1d 2h
eOnzErG vs TBD
G5 vs Nesh
Patches Events
1d 7h
Replay Cast
1d 16h
Wardi Open
1d 17h
Afreeca Starleague
1d 17h
Jaedong vs Light
[ Show More ]
Monday Night Weeklies
1d 23h
Replay Cast
2 days
Sparkling Tuna Cup
2 days
Afreeca Starleague
2 days
Snow vs Flash
WardiTV Invitational
2 days
GSL
3 days
Classic vs Cure
Maru vs Rogue
GSL
4 days
SHIN vs Zoun
ByuN vs herO
OSC
4 days
Replay Cast
5 days
Escore
5 days
The PondCast
5 days
WardiTV Invitational
5 days
Replay Cast
6 days
CranKy Ducklings
6 days
RSL Revival
6 days
SHIN vs Bunny
ByuN vs Shameless
WardiTV Invitational
6 days
Liquipedia Results

Completed

Escore Tournament S2: W5
WardiTV TLMC #16
Nations Cup 2026

Ongoing

BSL Season 22
ASL Season 21
CSL 2026 SPRING (S20)
IPSL Spring 2026
KCM Race Survival 2026 Season 2
KK 2v2 League Season 1
Acropolis #4
SCTL 2026 Spring
RSL Revival: Season 5
2026 GSL S1
BLAST Rivals Spring 2026
IEM Rio 2026
PGL Bucharest 2026
Stake Ranked Episode 1
BLAST Open Spring 2026
ESL Pro League S23 Finals
ESL Pro League S23 Stage 1&2
PGL Cluj-Napoca 2026

Upcoming

BSL 22 Non-Korean Championship
CSLAN 4
Kung Fu Cup 2026 Grand Finals
HSC XXIX
uThermal 2v2 2026 Main Event
Maestros of the Game 2
2026 GSL S2
Stake Ranked Episode 3
XSE Pro League 2026
IEM Cologne Major 2026
Stake Ranked Episode 2
CS Asia Championships 2026
Asian Champions League 2026
IEM Atlanta 2026
PGL Astana 2026
TLPD

1. ByuN
2. TY
3. Dark
4. Solar
5. Stats
6. Nerchio
7. sOs
8. soO
9. INnoVation
10. Elazer
1. Rain
2. Flash
3. EffOrt
4. Last
5. Bisu
6. Soulkey
7. Mini
8. Sharp
Sidebar Settings...

Advertising | Privacy Policy | Terms Of Use | Contact Us

Original banner artwork: Jim Warren
The contents of this webpage are copyright © 2026 TLnet. All Rights Reserved.