The Diffie-Hellman Key Exchange allows two strangers who have no prior knowledge about each other to securely establish a secret key that they can use to communicate securely even if all of their messages are being intercepted by an eavesdropper.
In this article, we will learn about the Diffie-Hellman Key Exchange and the Miller-Rabin Primality Test. We will describe the six steps of the Diffie-Hellman Key Exchange at a high level and then work through a brief example of the Key Exchange. We will then describe the five steps of the Miller-Rabin Primality Test and work through a brief example…
In today’s article, we’re going to add a health bar to an iOS app entirely programmatically in Swift 5. In the process, we’ll gain experience with UIProgressView, UIImageView, GestureRecognizer, Constrains, and Animations.
By the end of this tutorial, you will have made an enemy on the screen with a health bar above its head. When you click on the enemy, it will shrink then grow through UIView animations while its health bar slowly decreases.
Step 1: Create a new XCode project and then add the png image found at https://drive.google.com/drive/u/0/folders/1gBVQQp-1lb2EIdLoL106vpDWsYpofmKF to your Assets.xcassets folder.
Step 2: Creating and setting up…
I recently came across a coding interview question that asks the programmer to distribute some number of items, to a row of n people in the following way:
We start our first turn by giving 1 item to the first person, 2 items to the second person, and so on until we give n items to the last person. Then, we go back to the start of the row and begin our second turn, giving n+1 items to the first person, n+2 items to the second person, and so on until we give 2n items to the last person. This…
There are four built-in data structures in Python — lists, dictionaries, sets, and tuples. Knowing, or at least being familiar with, the time complexities of the operations associated with each data structure will allow you to judge when your algorithm is getting faster or slower.
For the purpose of this article, we will be discussing each operation’s time complexity in terms of its big O time as the industry has defined it. Here’s a refresher on some of the most common time complexities found in computer science.
Now, let's get into each data structure and their respective time complexities for each operation.
Assuming a list named lst of length n exists:
Assuming a dictionary named dict of length n exists:
Assuming a set named s of length n exists and s1 and s2 exist:
When it comes to Computer Science, there are four main algorithms that you need to have in your arsenal. Bubble sort, selections sort, merge sort, and quickSort. Adding just these four algorithms to your collection of knowledge will certainly make you a better and more efficient programmer.
Description: Start at the beginning of the list and swap the first two elements if the first is greater than the second. Then, go to the next pair, making continuous sweeps of the list and so on until the list is sorted.
Runtime: O(n²) average and worst case. Memory: O(1)
Step 1: Make a new Xcode project and delete Main.storyboard as we won’t be needing it for this tutorial.
Step 2: Next, open Info.plist and delete the“Main storyboard file base name” line and the “Storyboard Name” line
For this tutorial, we will be embedding a horizontal UIScrollView inside a vertical UIScrollView
Step 1: Define our variables and set up our ViewController’s subviews
Step 2: Now that we have implemented all of our code in ViewController.swift all we need to do is add 6 pictures to our Assets.xcassets folder. If you want the images to appear, then ensure that you have named the image files the same as I have (i.e. 1, 2, 3, 4, 5 and 6).
And that’s it! Enjoy your newfound knowledge of UIScrollViews!
Detecting whether a user has exited your application (e.g. pushed the home button) can be highly beneficial in creating an iOS app that is reactive to what its users are doing. For example, if your app has an online status for its users, then detecting whether a user has exited the app is required for this feature to work.
Upon creating a new Xcode project, you’ll notice that it comes with the SceneDelegate.swift file. The SceneDelegate is essentially in charge of your app’s lifecycle, and it is here where we can detect if a user exits your iOS App. Navigate…
For the sake of this article, I will be doing everything programmatically.
2. Set the textField’s delegate to self. Place paste this code on the line below the textField’s constraints (under line 21).
3. Extend the ViewController class with the following code. The textFieldShouldReturn function will be called whenever the return button is clicked.
4. Now finally combine all of the code so that it looks like this
Congratulations! You now know how to programmatically make the keyboard disappear when the return button is clicked!