« first day (2146 days earlier)      last day (2810 days later) » 

11:05 AM
I know about crypto stuff in .NET
 
@mark333...333...333 what is the code around IEnumerable<Project.Models.MyModel>?
 
@War I feel the same about ValueTuple<>. ? is descriptive because we got used to it. Tuple decomposition will soon feel the same, I think.
Imagine you had to split declaration and assignment, like you do in old C code or Pascal. int i; i = 5. Doesn't it feel too verbose? That's what tuple decomposition tries to do.
 
11:18 AM
Hey guys, I have mac OSX and I have a class named "C-programming" in linux, and the lecturer has told us all that we need to install a virtual machine with Ubuntu.
What I am asking is, is there anything you can do in ubuntu that you cannot do in Mac OSX when it comes to C programming?
 
@tomSurge Yeah, program for Linux.
 
@tomSurge well you can also cut butter with a chainsaw
the point is to have the same environment as you do on the uni machines
 
Yeah, but the only thing we are going to do is making .c files and compile them
 
otherwise you'll spend time learning how different is your environment than the other
 
and I can do both of those in both OS'es
 
11:21 AM
And I only make .cs files and compile them.
Environment matters
Mac is not Linux. If you're being taught about Linux APIs, your Mac is useless.
 
I see
 
Well if the subject isn't new to you, why are you learning it
 
If it's generic ANSI-C APIs, then it works on any platform.
But usually, that's not the case.
 
I see, thanks for the input
Will download a VM then
 
Or you should ask your lecturer for clarification.
 
11:22 AM
@tomSurge At any point when you'll hit a difference between the environment your teacher has and you have, and the instructions which are provided won't help you, you'll spend time figuring out how it works on your machine
 
He also might have a requirement "When you hand in your assignment, it must work on Ubuntu 14.04 with the Eclipse IDE". In that case, you have no choice but to test there anyway, so why not develop there to begin with?
 
Ok, I see the point, so the reason for my lecturer to ask for everyone to program in Ubuntu, is for everyone to have the same environment, seeing as some people have macs and some other have windows
Makes more sense
 
@tomSurge Yup. He doesn't want students - and himself - to waste time on environments and compatibility, and instead focus only on the code itself.
 
War
@AvnerShahar-Kashtan I get what it's trying to do but it's way more descriptive to just return a DTO than this on the fly Tuple thing IMO
 
@War A DTO, for me, is a model entity. Sometimes I don't really need a full-scale entity.
I have a GetItemsFromDb method that receives, among its parameters, a MaxItemsToRetrieve. Then, I found out I wanted to know the original count as well, so I knew to display "Showing X items out of Y".
 
War
11:30 AM
DTO and an Entity are two completely different things ... you are trying to pass around a few pieces of data a Date Transfer Object is the right thing for that
 
So now my GetItemsFromDb could either have an out param (eww), or return a new DTO, "ItemsWithOriginalCount", which is ad-hoc and annoying.
(And is what I ended up doing)
 
War
Adhoc and annoying ?
you are defining your output
that's like saying method signatures are adhoc and annoying
 
This would also define my output, and much more clearly:
`public (List<Item> items, int originalCount) GetItemsFromDb(...)`.
 
War
public ItemsFromDbResult GetItemsFromDb(...)
^ more descriptive to me
 
@War Consider the other direction. Would you want to define an Arguments DTO instead of passing multiple parameters to a function?
 
War
11:33 AM
yeh what's wrong with that?
 
@War You never have any void MyMethod (int arg, string otherArg)?
Because, now that I think about it, this is identical - multiple in arguments, multiple out return values.
 
War
yeh but its not
you are only returning 1 object still
should that object be (foo, bar) or SomeDTO
 
yeh, it's a weird distinction
 
A tuple is multiple values. That's what it represents.
 
look (int, int) void YourMethod(int, int)
 
War
11:34 AM
@KendallFrey i agree ... but its still 1 object
 
Sure, you can return one tuple, but that doesn't mean that's what your code means.
 
War
@milleniumbug that gives the impression of 2 in 2 out
but its not
 
@War No, I'm returning multiple values. That's the conceptual behavior. Just because it's implemented by a ValueTuple<> behind the scenes is immaterial.
@War Of course it is. That's exactly what it is.
 
War
var result = YourMethod(int, int) <--- that's how you are going to call it
 
@War how can you observe the difference
 
War
11:36 AM
where did you put it ?? ... in 1 place
 
@War or var (res1, res2) = YourMethod(int, int)
 
No, that's what the tuple decoupling syntax is for.
`var (items, originalCount) = GetItemsFromDb();`
 
War
there's now way to say ...
var (foo, bar) = SomeMethod(a,b)
that's just messed up
 
@War my point is that distinction is arbitrary
 
No, that's very handy
 
11:37 AM
@War Only because you're stuck on "a method only returns one value".
 
A tuple doesn't just represent multiple values as one. It is multiple values, in most pure applications such as math.
 
War
I think it will result in some really messed up code
 
look at from the other side: a method accepts only one argument
 
@War JS has destructuring assignment now. It's really very useful.
 
War
so would that allow this kinda thing ....
Method1(Method2())
where Method1 accepts 2 args
 
11:38 AM
Haskell has had destructuring pattern matching for, like, ever.
 
War
@KendallFrey JS is fucking disaster of a language
@KendallFrey as for haskell steve-yegge.blogspot.co.uk/2010/12/…
 
@War Only if method1 accepts its parameters as a tuple rather than an arglist, or the language is extended
 
War
@KendallFrey and that's my point ... a tuple is 1 arg
 
@War distinction between an arglist and a tuple is arbitrary
 
War
it's 1 object
 
11:40 AM
arglist is a tuple
 
War
you are not returning 2 things are still returning (in effect a DTO)
 
except it's special cased by a language
 
@War The original language, yes. Almost everything they're changing now is making it way better.
 
War
@KendallFrey yeh including typescript which make JS more C# like
now you want to make C# more JS like
jeez
 
@War old and meaningless
 
11:40 AM
Anyone know that why cant i change the Background Color of this metro tile
thanks in advance
i have teamviwer if soneone wants
 
War
@KendallFrey still relevant ... haskell blows
 
@War Yeah, but wouldn't it be nice if a tuple could be treating as what it represents? That's where destructuring etc. come in.
@War No. It doesn't.
 
Imagine a C# dialect which would accept only 1-argument functions
 
@milleniumbug Classes all over the place
 
Tuple<int, string> Function(Tuple<int, int, long>)
 
War
11:43 AM
meh fact is ... just don't see the point in this functionality in the language , it's basically just here to allow peculiar design, one of the best things about C# is that they have deliberately kept it clean ... all this constant "improvement" ultimately ends up in us having c+++
 
Clean? Clean?! C#? Hah!
 
@milleniumbug That would only be ok if it would use partial application, not just tuples
 
C# has 12+ years of bloated crap tacked on one another.
 
@War alright, alright, I'll get off your lawn
 
War
@RoelvanUden yeh, that's my point ... its getting stupid
 
11:44 AM
^^^
 
@KendallFrey my point is presenting how an arglist is a special-cased tuple
 
@milleniumbug In C# it does behave the same
 
LINQ is a huge break from the original C# design. And it's a huge improvment.
 
except it's not first-class
 
War
it was a nice language at birth ... people insist that because language X has it that C# must have it because "I can do some stupid shit in it"
 
11:44 AM
@War That doesn't mean the concepts aren't good
 
Let's count how many ways we have to do things on the background
 
I don't want to keep clean for cleanliness' sake. C# without LINQ is a much inferior language.
 
War
@RoelvanUden that's not C# ... that's .NET
 
also delegate(int lol) { return lol+1; } vs lol => lol + 1
 
Except the C# language design specifically added keywords and crap
 
11:45 AM
Situations like this are why I wish languages were designed to avoid backwards compatibility
 
War
@AvnerShahar-Kashtan that's not C# that's .NET
 
Events are a fucking nightmare too.
 
"let's not add irrelevant crap, we already have a syntax for declaring functions"
 
@milleniumbug vs (+1)
Haskell wins again
 
@War You're splitting hairs here, but fine. Lambas, then, like @milleniumbug mentioned.
 
11:46 AM
@milleniumbug Sounds like some people would be better off with Assembly
 
It's splitting hairs because C# and .NET are developed in lockstep, with features of one designed to complement the other.
 
War
you guys are saying C# is bloated because the .Net team created 20 ways to do the same shit over time
but .NET and C# are not the same
 
2 mins ago, by milleniumbug
also delegate(int lol) { return lol+1; } vs lol => lol + 1
 
They effectively are. We can't really split Java from the Java Runtime either, can we?
 
this is C#
 
11:48 AM
Or PHP without the PHP standard library.
 
@War C# is bloated precisely because the old half-assed ways of doing things are still around and we can't get rid of them. Take implicitly nullable reference types, for example. Almost no one thinks they're a good idea.
 
And it just won't go away :-(
 
War
@RoelvanUden no but the clr ecosystem is different, I can't write C# code against the Java framework, but I can write C#, C++, F#, VB, ect against the same .NET libraries
 
is there any one who has worked with serial port?
 
depends
 
11:49 AM
@Farshad I've plugged mice into them, if that's what you want.
It's not.
 
Aug 22 at 12:29, by Roel van Uden
People, just ask your question. If somebody knows something to help you, and feels like it, they will. If you don't ask your question immediately, we first have to go through a huge 'try to extract the actual question' game first.
 
War
@KendallFrey if anything thats just an arg to remove stuff not add more shit
 
except you can't do that reliably
 
@War It's an argument that change isn't inherently bad.
 
@War The language wasn't design to have stuff removed. This is another gripe.
But they're planning to add shit to make it possible to have non-nullable reference types.
 
11:50 AM
@AvnerShahar-Kashtan i have a 3g modem.i told my problem in stackoverflow.com/questions/39242707/…
 
War
@KendallFrey isn't hat why we now have roslyn ... you can probably write an extension / plugin for that to remove stuff ... might be messy though
 
It's poorly designed and unintuitive, because the original design was flawed
@War The problem is the language isn't designed to handle that
 
@KendallFrey The main problem with non-nullable reference types is default(T)
 
War
@AvnerShahar-Kashtan agreed but we aren't talking about change here ... we are talking about adding shit that exists in other languages mainly just because it exists in other languages ... how is that a good thing?
 
If it were up to me, languages would be backwards incompatible, with pragmas that tell the compiler which version of the spec the code uses.
 
War
11:52 AM
@milleniumbug who even uses that?
 
I'd jump in with that ^^
 
@AvnerShahar-Kashtan i receive some string from modem but when i send commands it wont return any thing
 
@War I last used it two days ago
 
@War No, it's about adding stuff that addresses existing problems and concerns voiced by many users.
@War I do. Often.
 
War
@KendallFrey re-design that code block it's broken
@AvnerShahar-Kashtan you too
 
11:53 AM
@War No, it's not. It's generic. There's a difference.
 
@War How can you say my code is broken when you haven't seen it?
 
War
@AvnerShahar-Kashtan uh ... yeh ... most my code is generic ... there is no good reason to use default(T) imo
 
FTR, I made a dynamic Default method that works with a runtime type instead of a compile-time type
 
@War Write a collection class without relying on having a default value in your types
 
War
@milleniumbug why do you need a default value ??
you either have a value given to you by the calling code or you don't
stop making assumptions in your code
 
11:54 AM
Well, I'm a C++ user and I don't need it there
 
War
^ that says it all
 
allocate an array
 
War
C++ guys usually think they need everything
 
@War What do you think Nullable<T>.GetValueOrDefault() uses?
 
War
including a new type of cpu to work for their particular way of thinking right now
 
11:55 AM
@milleniumbug cons ftw
 
War
@AvnerShahar-Kashtan again, another method I never use
 
@War good job at assuming
 
This is the most exciting discussion this room has had in days
 
War
lol
really?
dull room :)
 
@War also C++ works on more CPUs than C# ever will, so cut down the bullshit
 
War
11:57 AM
@milleniumbug prove it
 
That's an unprovable and unfalsifiable hypothesis.
 
Arduino, sold as Genuino, due to a trademark dispute, outside the U.S. and U.K., is a hardware and software company, project, and user community that designs and manufactures computer open-source hardware, open-source software, and microcontroller-based kits for building digital devices and interactive objects that can sense and control physical devices. The project is based on microcontroller board designs, produced by several vendors, using various microcontrollers. These systems provide sets of digital and analog input/output (I/O) pins that can interface to various expansion boards (termed...
 
War
c++ doesn't run on that
 
it does
 
War
no it doesn't
 
11:58 AM
First google result says it does
 
@War it actually does
 
War
c++ => compiler => machine code => hardware
I can do the same with c# and get it to run on that
 
Good god.
Are you really going there
 
War
c# can be compiled to native code to run on pretty much everything these days
 
@War The tricky part is working without the stdlib, or compiling a subset of it for the duino as well
 
12:00 PM
@War Really? Make it run on my arduino please.
 
War
jeez ... google ...
 
the main problem isn't a language, or even .NET
 
it's assuming an environment where there isn't
 
War
code sample from first link that the guy is running on his arduino
hmm ok
my bad ... didn't read that
 
12:01 PM
Well, this discussion has officially gone:
 
I just want to go home.
 
War
meh im off to go mess about with this cryptoshit
 
today feels so .. non work day.
 
War
^
 
Your discussions btw are savage. I love it when you guys unite.
 
12:08 PM
I actually felt we really managed to stay civil.
 
@ElieSaad I'm a Lounge<C++> regular, this is my daily reality
 
The JavaScript room, which I no longer frequent, also makes our nastiest days feel like a polite dinner party.
 
War
I like the discussions in here
they aren't as savage as some on the networrk
c++ dba and game programming rooms are brutal
c# rooms tend to be mostly just rant
jeez why does encryption in .Net have to be so douchey
like 20 lines of code ... where's my encryption object I can call encrypt(someshit) on
 
@War ProtectedData.Protect()?
 
@War Encryption is rather a broad topic. What are you doing ;)
 
War
12:13 PM
i need to use AES and salts and shit
430
Q: Encrypt and decrypt a string

NotDanCan someone give me the code to encrypt and decrypt a string in C#?

basically we have a public endpoint that anyone can call but it allows poeple to send emails
we want the user to have permission but only when the business logic makes that call
 
encryption is difficult
 
War
so rather than it being a hard coded permission rule we have the business logic make the call by adding a "token" to the call header
it needs to create an encrypted string, dump that in the header then the remote endpoint decrypt and decide if the user is ok to "send this email on this particular occasion"
 
If you have tokens, what is the encryption even for?
 
War
we have auth tokens
 
War
12:16 PM
the user is already authorised to use our endpoints
this is an additional logic check to confirm the call actually came from our back end and not the user directly
we thought of many ways to handle this, the simplest of them was to add a custom header with a special token in it for back end generated calls
 
And there is no communication between the two end points to verify?
 
@milleniumbug Tell me about that room. Let me join your reality.
@AvnerShahar-Kashtan yeah normally it becomes more savage. Last time some tough words ran at the table.
 
War
basically means we can authorise as the user and the endpoint receiving the call can simply decrypt the secondary token to determine that the call came from our business logic
 
Then why don't you just sign it?
Encrypting it is the wrong approach imho
 
Hey guys, I'm reading this binary value from DB 0x0000000000000000 into a byte[]
 
War
12:18 PM
that's essentially what this is, a signed json call to the remote endpoint
The problem is there are situations where the signing is not needed
 
@ElieSaad Lounge<C++>, and when it gets heated, it is hoooooot
 
On one form I need to show this as string, but when I try this System.Text.Encoding.UTF8.GetString(byteArray) it gets converted into some gibberish data
 
@SamyS.Rathore A byte[] doesn't tell you what structure you want it in. 0x00000000 can be represented as many things - an int, short, long, whatever, each with a different byte[] representation.
 
currently pretty cold
 
I tried converting in Base64 as well
but that also looks different than the original value
 
12:20 PM
@SamyS.Rathore The original column is VARBINARY?
If so, they byte[] representation is simply new byte[1] { 0 } - a single 0 value.
 
its Binary
 
@milleniumbug pft. When u get some action, tag me up.
 
@AvnerShahar-Kashtan Can I get a string represntation from that byte[]??
I need to export the value to XML
to be used by another procedure
 
@SamyS.Rathore What string representation? The string "0x000000"?
 
@SamyS.Rathore What string were you expecting? A bunch of zeroes won't yield any characters meant for humans.
 
12:24 PM
@AvnerShahar-Kashtan yeah, something like that
 
How many zeroes?
 
What do you mean "something like" it?
You have to actually explain what you're trying to do
 
this is the value I see in the DB 0x0000000000000000
 
Stop and think about what your data means. You have a binary blob of data - it can be an image, an MP3, a string or whatever. Currently, it's empty - just a single byte equalling 0.
 
@SamyS.Rathore That's just zero
 
12:25 PM
0x000000000009427A or 0x000000000002F5AB
 
To convert it to a string like you want, you have to take that binary blob, cast it to a number (which can fail of course - you can only put 32bits in an int, of course), and then format the number as a hexadecimal string.
 
those are numbers
 
Does that make sense? If it does - sure, go ahead.
 
3 significant bytes each
What do you expect as output when given 0x000000000009427A?
 
If I hold it in a datatable and use GetXML() , It looks the same
for e.g <VersionNumber>0x000000000002F5AB<VersionNumber>
 
12:27 PM
byte[] binaryData = //fromDb.
long numericalRepresentation = BitConverter.ToInt64(binaryData); // can crash!
string stringRepresentation = numericalRepresentation.ToString("X8"); // hexadecimal string padded to 8 chars.
 
War
@RoelvanUden out of curiosity ... knowing me i got the wrong meaning of what you are saying about signing ... what do you mean specifically?
 
@AvnerShahar-Kashtan will this work? I'll give it a try
 
@SamyS.Rathore Roughly. I wrote it here, not in VS, so the syntax might be a bit different.
But do you understand what these lines do?
A few notes - ToString("X8") doesn't add the 0x prefix, you'll have to add it yourself.
Also, ToInt64 needs the byte[] to be exactly 16 bytes long. You'll have to pad it.
 
@War Encryption/decryption is used to keep something secret. Both sides need access to the secret to encrypt/decrypt, but the validity of a decryption is not guaranteed. It just ends up as whatever, even if the input was "not valid". Signing is all about attaching identity to a piece of data, and allowing another party to verify that the data received was issued by said party and was not altered.
Signing has the upside of having private/public keys and just indicates "Hey this data was indeed issued by n"
 
Yeah but then anyone can read it. ^
 
War
12:34 PM
@RoelvanUden but doesn't signing include encrypted data? (in a secure implementation)
 
@ElieSaad That wasn't his goal.
@War Not necessarily.
 
War
like a client cert when I use SSL for my website
 
Exactly, but SSL is more than just signing.
Think SAML for example
 
With encryption, you use someone's public key to encrypt something that can only be decrypted by the private key. With signing it's a bit the inverse of that - you sign something with your private key that can be verified by anyone with your public key.
 
War
ok i have 2 api's
they both share some keys
one creates a dto, serialises it then encrypts it and adds that to a custom header
 
12:36 PM
The problem of just encryption is simple; how do you know the decrypted data is valid?
 
War
that's basically how i'm "signing" the call
 
Yep as roel said. You need a verification bit, if you can provide that.
 
War
the decrypted data is encrypted using keys shared by the 2 applications
 
But what if I manipulate a byte and throw it into your API?
 
War
then it won't decrypt
 
12:37 PM
It'll happily decrypt it. How do you know it's not manipulated?
 
War
the call will be rejected
 
How do you determine that?
 
how do you know? @War
 
Hi there, in MVC HttpPostedFileBase returns null after using jquery.mobile-1.4.5.min.js
 
War
oh so in the event you can somehow manipulate the data in a way that it still makes sens on the other end you're saying I have a problem?
so how do I sign the request in such a way that that is not possible?
 
12:38 PM
Exactly. And it's not very theoretical, all it takes it replacing one byte that is still considered okay by whatever comes next.
For example, HMAC over the encrypted payload.
 
@War I am A, you are B, and roel is C. If A sends to B a message, and C intercepts the message and changes whatever inside of it, and sends it to B. B would decrypt whatever C changed without knowing.
 
War
I'm way out my comfort zone here ... surely if the message was tampered with it wouldn't decrypt right
 
False ;-)
Encryption/decryption is merely flipping bits.
 
That is for you to detect
 
This is why you sign things.
 
War
12:41 PM
ok so do you guys know how I can do signing right ?
a code sample would help
 
Sure, HMAC is an option.
But honestly, @War, you're way out of your comfort zone here.
Use a proven algorithm.
 
War
430
Q: Encrypt and decrypt a string

NotDanCan someone give me the code to encrypt and decrypt a string in C#?

i'm going off this atm
does that look right?
 
For example, AES-GCM (which is AES + GMAC)
That answer is terrible. AES can be done in 2 lines. But don't invent your own system.
Use AES-GCM or something.
 
C# libraries contain an AES algorithm? Nice!
 
Yeah, they do. Not all modes of course
Otherwise look into BouncyCastle
 
War
12:43 PM
@RoelvanUden 2 lines ?
 
I think you declare the AES object first line. Second line would assign it to your string or whatever :P
 
0
Q: AES-GCM with BouncyCastle throws "mac check in GCM failed" when used with IV

TmesusI'm relatively new to developing something with encryption. Right now I'm trying to write a class which encrypts and decrypts Strings using BouncyCastle with AES-GCM. I read about the things you have to consider when implementing encryption. One of them was that you should always use a randomized...

Start here.
 
War
hmmm k ... thx
 
@ElieSaad Yeah :3
Disclaimer: I went down this rabbit hole and learned way too much about cryptography and their implications. AES-GCM is currently one of the better standards, is open, proven, and widely used. There are other applicable ones for your use case, but this is one of the best.
(AES-GCM will throw if you manipulated a bit, because, it has signing built in)
(and BouncyCastle is the same for Java and C#)
 
Cool, and nice to know.
 
War
12:47 PM
ah neat ... thx @RoelvanUden and as @scheien said, very nice to know :)
 
@RoelvanUden tell me, about that cryptography hole you went in.
 
@ElieSaad I kind of went on a limb and wrote myself an experimental virtual cryptographic file system. So, all the way from different modes of operation (e.g. block implications of non-safe bytes) to manipulation attacks (signing and whatnot) down to re-ordering attacks (bind blocks to locations on disk) and replication attacks, all the way down to the FS blocks.
... It was a lot of fun.
 
@RoelvanUden seems like it! And about AES-GCM, it's more or less like a digital envelope, nope?
 
An envelope?
 
Yeah, I would encrypt using your public key, with a random generated key. And the message would be encrypted by that random key.
Meh that would be missing the integrity part. nvm it
 
War
12:58 PM
^ what i have so far
probably needs work though
 

« first day (2146 days earlier)      last day (2810 days later) »